@intra-mart/accel 2.0.0 → 3.0.0-rc.202611260721
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/README.md +10 -4
- package/assets/githooks/.githooks/pre-commit/pre-commit_en +71 -32
- package/assets/githooks/.githooks/pre-commit/pre-commit_ja +67 -33
- package/assets/githooks/.githooks/pre-commit/pre-commit_zh_CN +66 -32
- package/assets/runtime/ensure.mjs +27 -16
- package/dist/asset/deployer.d.ts +0 -2
- package/dist/asset/deployer.js +1 -6
- package/dist/asset/installer.d.ts +18 -2
- package/dist/asset/installer.js +94 -17
- package/dist/commands/attach-existing-files.d.ts +7 -0
- package/dist/commands/attach-existing-files.js +47 -1
- package/dist/commands/attach.d.ts +3 -1
- package/dist/commands/attach.js +21 -5
- package/dist/commands/deploy.d.ts +5 -1
- package/dist/commands/deploy.js +10 -3
- package/dist/commands/detach.d.ts +3 -1
- package/dist/commands/detach.js +16 -4
- package/dist/commands/init.d.ts +3 -1
- package/dist/commands/init.js +9 -4
- package/dist/commands/login.d.ts +8 -0
- package/dist/commands/login.js +13 -1
- package/dist/commands/mobile/attach.js +2 -3
- package/dist/commands/mobile/init.js +5 -2
- package/dist/commands/mobile/shared.d.ts +1 -1
- package/dist/commands/mobile/shared.js +5 -2
- package/dist/commands/switch.d.ts +2 -0
- package/dist/commands/switch.js +2 -2
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +1 -1
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/git/config-file.d.ts +10 -2
- package/dist/git/config-file.js +177 -94
- package/dist/git/config-scopes.d.ts +17 -0
- package/dist/git/config-scopes.js +33 -0
- package/dist/git/index-file.js +23 -4
- package/dist/git/read-capped.d.ts +1 -0
- package/dist/git/read-capped.js +6 -3
- package/dist/git/repo-discovery.d.ts +26 -0
- package/dist/git/repo-discovery.js +213 -0
- package/dist/git/untracked.d.ts +1 -0
- package/dist/git/untracked.js +23 -1
- package/dist/git/worktree-status.js +26 -21
- package/dist/i18n/en.js +72 -6
- package/dist/i18n/ja.js +72 -6
- package/dist/i18n/zh_CN.js +72 -6
- package/dist/interactive/credentials-prompts.d.ts +4 -1
- package/dist/interactive/credentials-prompts.js +2 -1
- package/dist/interactive/hook-confirm.d.ts +2 -0
- package/dist/interactive/hook-confirm.js +16 -0
- package/dist/lib.d.ts +1 -0
- package/dist/utils/command-exists.d.ts +5 -0
- package/dist/utils/command-exists.js +7 -6
- package/dist/utils/external-command.d.ts +0 -1
- package/dist/utils/external-command.js +1 -29
- package/dist/utils/githooks-remove.d.ts +27 -0
- package/dist/utils/githooks-remove.js +196 -0
- package/dist/utils/githooks-state.d.ts +80 -0
- package/dist/utils/githooks-state.js +364 -0
- package/dist/utils/githooks-sync.d.ts +11 -2
- package/dist/utils/githooks-sync.js +360 -68
- package/dist/utils/managed-marker.d.ts +1 -0
- package/dist/utils/managed-marker.js +1 -0
- package/dist/utils/mcp-generate.d.ts +5 -1
- package/dist/utils/mcp-generate.js +13 -4
- package/dist/utils/output-tail.d.ts +11 -0
- package/dist/utils/output-tail.js +29 -0
- package/dist/utils/runtime-ensure.js +10 -4
- package/package.json +1 -1
- package/dist/git/repo-layout.d.ts +0 -5
- package/dist/git/repo-layout.js +0 -44
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ accel init my-project
|
|
|
86
86
|
| `--no-git-init` | git initをスキップ | `false` |
|
|
87
87
|
| `--skip-install` | 依存インストールをスキップ | `false` |
|
|
88
88
|
| `--asset-server-url` | 資材を取得するgitリポジトリのURL(HTTP(S) のみ) | `https://github.com/accelplatform/skills` |
|
|
89
|
-
| `--asset-ref` | 資材リポジトリから取得するブランチ/タグ | `
|
|
89
|
+
| `--asset-ref` | 資材リポジトリから取得するブランチ/タグ | `experiment` |
|
|
90
90
|
|
|
91
91
|
### `accel attach`
|
|
92
92
|
|
|
@@ -220,6 +220,7 @@ accel login
|
|
|
220
220
|
|
|
221
221
|
- **APIキーは機密情報のため、`.accel/credentials.json` は自動的に `.gitignore` に追加されます**(コミット対象外)。
|
|
222
222
|
- 保存に成功すると、エージェント用の MCP 設定ファイルを自動生成します([MCP 設定の自動生成](#mcp-設定の自動生成))。
|
|
223
|
+
- あわせて、API キーの誤コミットを防ぐ pre-commit フックを配置します([pre-commit フックの自動配置](#pre-commit-フックの自動配置))。
|
|
223
224
|
|
|
224
225
|
#### オプション一覧
|
|
225
226
|
|
|
@@ -227,6 +228,7 @@ accel login
|
|
|
227
228
|
|---|---|---|
|
|
228
229
|
| `--endpoint` | iAPのベースURL(環境変数 `ACCEL_ENDPOINT` でも指定可) | 保存値 / 対話で入力 |
|
|
229
230
|
| `--api-key` | OAuth Bearerトークン(**環境変数 `ACCEL_API_KEY` 推奨**) | 保存値 / 対話で入力 |
|
|
231
|
+
| `--allow-parent-repo-hook` | プロジェクトが git リポジトリのサブフォルダーにある場合に、確認せずにリポジトリへ pre-commit フックを配置する(非対話モードでは、指定した場合だけ配置する) | `false`(対話で確認 / 非対話では配置しない) |
|
|
230
232
|
| `--non-interactive` | 非対話モード([CIでの利用](#ciでの利用)) | `false` |
|
|
231
233
|
|
|
232
234
|
### `accel deploy`
|
|
@@ -280,7 +282,7 @@ cd my-project
|
|
|
280
282
|
accel detach
|
|
281
283
|
```
|
|
282
284
|
|
|
283
|
-
配備時から変更されていないファイルと `.accel/` ディレクトリを削除します。ユーザーが編集したファイルは残り、MCP 設定ファイルからは CLI が生成したエントリのみが除去されます。
|
|
285
|
+
配備時から変更されていないファイルと `.accel/` ディレクトリを削除します。ユーザーが編集したファイルは残り、MCP 設定ファイルからは CLI が生成したエントリのみが除去されます。CLI が配置した pre-commit フックも削除します。
|
|
284
286
|
|
|
285
287
|
## CIでの利用
|
|
286
288
|
|
|
@@ -412,10 +414,14 @@ Expo 公式 skills は CLI の管理対象ではありません。更新は `npx
|
|
|
412
414
|
|
|
413
415
|
## pre-commit フックの自動配置
|
|
414
416
|
|
|
415
|
-
MCP 設定ファイルに埋め込まれた API キーを誤って git
|
|
417
|
+
MCP 設定ファイルに埋め込まれた API キーを誤って git にコミットしてしまう事故を防ぐため、接続情報の保存時(`accel login` など)に、API キーを検出する pre-commit フックを自動配置します。
|
|
416
418
|
|
|
417
419
|
- フックは、ステージされた `.json` / `.toml` ファイルの追加行に intra-mart OAuth クライアントキー形式の文字列が含まれる場合、コミットをブロックします。確認の上でコミットしたい場合は `git commit --no-verify` で回避できます。
|
|
418
|
-
-
|
|
420
|
+
- フックは git リポジトリの pre-commit フック(`.git/hooks/pre-commit`)として配置し、配置したときに場所を表示します。git worktree では、すべての worktree で共有されます。git の設定(`core.hooksPath` など)は変更しません。ただし、以前のバージョンが設定した `core.hooksPath` は、移行と `accel detach` のときに外します(後述)。
|
|
421
|
+
- プロジェクトが git リポジトリのサブフォルダー(モノレポなど)にある場合は、リポジトリ全体のコミットを検査するフックになるため、配置してよいか確認します。非対話モードでは `--allow-parent-repo-hook` を指定した場合だけ配置します。
|
|
422
|
+
- 既に別の pre-commit フックがある場合や、`core.hooksPath` を設定している場合は、配置せずに警告を表示します。このとき組み込み用のスクリプトをプロジェクトの `.githooks/` に置くので、既存の pre-commit フックから実行してください。
|
|
423
|
+
- 以前のバージョンの CLI は、`core.hooksPath` を `.githooks` に設定していました。次に接続情報を保存したときに、CLI がこの設定を新しい方式へ自動で移行し、結果を表示します。
|
|
424
|
+
- `accel detach` を実行すると、CLI が配置したフックも削除します(以前のバージョンが設定した `core.hooksPath` も外します)。
|
|
419
425
|
- この機能を無効化するには `.accel/settings.json` に `"gitHooks": false` を設定します。
|
|
420
426
|
|
|
421
427
|
## skill の npm 依存の自動インストール
|
|
@@ -6,12 +6,49 @@
|
|
|
6
6
|
# sensitive information, and blocks the commit if any are detected.
|
|
7
7
|
#
|
|
8
8
|
# How to enable:
|
|
9
|
-
#
|
|
10
|
-
#
|
|
9
|
+
# accel CLI places this hook when connection info is saved (e.g. accel login),
|
|
10
|
+
# normally as .git/hooks/pre-commit.
|
|
11
|
+
# To use it manually, run it from your existing pre-commit hook
|
|
12
|
+
# (e.g. bash <path to this file> || exit 1), or copy it to
|
|
13
|
+
# .git/hooks/pre-commit and make it executable.
|
|
11
14
|
#
|
|
12
15
|
set -euo pipefail
|
|
13
16
|
shopt -s nocasematch
|
|
14
17
|
|
|
18
|
+
# Pathspec interpretation settings that git passes to hooks (e.g. from
|
|
19
|
+
# git --literal-pathspecs commit) would change the filtering of the git diff
|
|
20
|
+
# below, so clear them. GIT_DIFF_OPTS is cleared too, because it would shift the
|
|
21
|
+
# line numbers shown for findings.
|
|
22
|
+
unset GIT_LITERAL_PATHSPECS GIT_GLOB_PATHSPECS GIT_NOGLOB_PATHSPECS GIT_DIFF_OPTS
|
|
23
|
+
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# Remove control characters from displayed names
|
|
26
|
+
# =============================================================================
|
|
27
|
+
|
|
28
|
+
# Characters used to control terminals (C0, DEL, C1). git quotes paths that
|
|
29
|
+
# contain C0 characters, but with core.quotePath=false it prints C1 characters
|
|
30
|
+
# (U+0080-U+009F in UTF-8) as is, and the path of this hook (built from $0 and
|
|
31
|
+
# $PWD) may contain anything. Remove them before display, as the CLI does.
|
|
32
|
+
CONTROL_CHARS=(
|
|
33
|
+
$'\x01' $'\x02' $'\x03' $'\x04' $'\x05' $'\x06' $'\x07' $'\x08'
|
|
34
|
+
$'\x09' $'\x0a' $'\x0b' $'\x0c' $'\x0d' $'\x0e' $'\x0f' $'\x10'
|
|
35
|
+
$'\x11' $'\x12' $'\x13' $'\x14' $'\x15' $'\x16' $'\x17' $'\x18'
|
|
36
|
+
$'\x19' $'\x1a' $'\x1b' $'\x1c' $'\x1d' $'\x1e' $'\x1f' $'\x7f'
|
|
37
|
+
$'\xc2\x80' $'\xc2\x81' $'\xc2\x82' $'\xc2\x83' $'\xc2\x84' $'\xc2\x85' $'\xc2\x86' $'\xc2\x87'
|
|
38
|
+
$'\xc2\x88' $'\xc2\x89' $'\xc2\x8a' $'\xc2\x8b' $'\xc2\x8c' $'\xc2\x8d' $'\xc2\x8e' $'\xc2\x8f'
|
|
39
|
+
$'\xc2\x90' $'\xc2\x91' $'\xc2\x92' $'\xc2\x93' $'\xc2\x94' $'\xc2\x95' $'\xc2\x96' $'\xc2\x97'
|
|
40
|
+
$'\xc2\x98' $'\xc2\x99' $'\xc2\x9a' $'\xc2\x9b' $'\xc2\x9c' $'\xc2\x9d' $'\xc2\x9e' $'\xc2\x9f'
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Stores $1 without CONTROL_CHARS in display_text (without a subshell).
|
|
44
|
+
sanitize_display() {
|
|
45
|
+
display_text=$1
|
|
46
|
+
local c
|
|
47
|
+
for c in "${CONTROL_CHARS[@]}"; do
|
|
48
|
+
display_text=${display_text//"$c"/}
|
|
49
|
+
done
|
|
50
|
+
}
|
|
51
|
+
|
|
15
52
|
# =============================================================================
|
|
16
53
|
# Collect the diff
|
|
17
54
|
# =============================================================================
|
|
@@ -21,7 +58,18 @@ shopt -s nocasematch
|
|
|
21
58
|
# The detection scope below is narrow, so the target files are filtered
|
|
22
59
|
# ahead of time via git's pathspec:
|
|
23
60
|
# - mcp config files (.json / .toml) where intra-mart OAuth client keys are written
|
|
24
|
-
|
|
61
|
+
# - package-lock.json is excluded, since its many hash-like strings are easily
|
|
62
|
+
# mistaken for auth keys
|
|
63
|
+
# core.quotePath=false keeps git from quoting non-ASCII paths ("a/\346...").
|
|
64
|
+
# The target files are already filtered here, so a file is never skipped just
|
|
65
|
+
# because its name cannot be parsed later.
|
|
66
|
+
# --no-ext-diff --no-textconv --inter-hunk-context=0 and the prefixes make the
|
|
67
|
+
# check read the staged content itself and report the right line numbers,
|
|
68
|
+
# regardless of user settings (external diff, textconv, diff prefixes, context
|
|
69
|
+
# lines between changes). Files git treats as binary (-diff / binary in .gitattributes, etc.)
|
|
70
|
+
# are not checked, so that large generated JSON does not slow down commits.
|
|
71
|
+
# Type changes from a symlink to a regular file (T) are checked too.
|
|
72
|
+
diff_output=$(git -c core.quotePath=false diff --cached --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ -U0 --inter-hunk-context=0 --no-color --diff-filter=ACMRT -- '*.json' '*.toml' ':(exclude,glob)**/package-lock.json' 2>/dev/null | tr -d '\0' || true)
|
|
25
73
|
if [ -z "$diff_output" ]; then
|
|
26
74
|
exit 0
|
|
27
75
|
fi
|
|
@@ -185,7 +233,8 @@ check_base64_tokens() {
|
|
|
185
233
|
fi
|
|
186
234
|
|
|
187
235
|
if (( is_match == 0 )); then
|
|
188
|
-
|
|
236
|
+
sanitize_display "$file"
|
|
237
|
+
findings+=("[$display_text:$lineno] Found an intra-mart OAuth client key string: ${token:0:12}...")
|
|
189
238
|
found=1
|
|
190
239
|
fi
|
|
191
240
|
done
|
|
@@ -195,19 +244,12 @@ check_base64_tokens() {
|
|
|
195
244
|
# Check every line of the diff
|
|
196
245
|
# =============================================================================
|
|
197
246
|
|
|
198
|
-
# The detection scope below is narrow, so only the following extensions are
|
|
199
|
-
# targeted:
|
|
200
|
-
# - mcp config files (.json / .toml) where intra-mart OAuth client keys are written
|
|
201
|
-
INCLUDE_FILE_RE='\.(json|toml)$'
|
|
202
|
-
|
|
203
|
-
# package-lock.json contains many hash-like strings that are easily
|
|
204
|
-
# mistaken for auth keys, so it is excluded from scanning.
|
|
205
|
-
EXCLUDE_FILE_RE='(^|/)package-lock\.json$'
|
|
206
|
-
|
|
207
247
|
current_file=""
|
|
208
248
|
current_line=0
|
|
209
|
-
|
|
210
|
-
|
|
249
|
+
# Whether we are inside a hunk (from an "@@" line). File headers ("--- a/...",
|
|
250
|
+
# "+++ b/...") come before the first hunk of each file. An added line whose content
|
|
251
|
+
# starts with "++ " also begins with "+++ ", so they are told apart by position.
|
|
252
|
+
in_hunk=0
|
|
211
253
|
|
|
212
254
|
while IFS= read -r line; do
|
|
213
255
|
case "$line" in
|
|
@@ -215,32 +257,22 @@ while IFS= read -r line; do
|
|
|
215
257
|
# e.g. diff --git a/path/to/file b/path/to/file
|
|
216
258
|
current_file="${line#diff --git a/}"
|
|
217
259
|
current_file="${current_file%% b/*}"
|
|
218
|
-
|
|
219
|
-
if [[ "$current_file" =~ $INCLUDE_FILE_RE ]] && [[ ! "$current_file" =~ $EXCLUDE_FILE_RE ]]; then
|
|
220
|
-
skip_file=0
|
|
221
|
-
else
|
|
222
|
-
skip_file=1
|
|
223
|
-
fi
|
|
224
|
-
;;
|
|
225
|
-
"Binary files "*|"GIT binary patch"*)
|
|
226
|
-
is_binary=1
|
|
260
|
+
in_hunk=0
|
|
227
261
|
;;
|
|
228
262
|
"@@ "*)
|
|
229
263
|
# e.g. @@ -12,0 +13,2 @@ ... -> get the starting line number (13) on the new-file side
|
|
230
264
|
if [[ "$line" =~ \+([0-9]+) ]]; then
|
|
231
265
|
current_line="${BASH_REMATCH[1]}"
|
|
232
266
|
fi
|
|
233
|
-
|
|
234
|
-
"+++ "*|"--- "*)
|
|
235
|
-
: # ignore diff header lines
|
|
267
|
+
in_hunk=1
|
|
236
268
|
;;
|
|
237
269
|
"+"*)
|
|
238
|
-
|
|
239
|
-
|
|
270
|
+
# Added lines are inside a hunk. Lines starting with "+" outside a hunk are file headers
|
|
271
|
+
if [ "$in_hunk" -eq 1 ]; then
|
|
272
|
+
content="${line#+}"
|
|
273
|
+
check_base64_tokens "$current_file" "$current_line" "$content"
|
|
274
|
+
current_line=$((current_line + 1))
|
|
240
275
|
fi
|
|
241
|
-
content="${line#+}"
|
|
242
|
-
check_base64_tokens "$current_file" "$current_line" "$content"
|
|
243
|
-
current_line=$((current_line + 1))
|
|
244
276
|
;;
|
|
245
277
|
*)
|
|
246
278
|
: ;;
|
|
@@ -262,6 +294,13 @@ if [ "$found" -eq 1 ]; then
|
|
|
262
294
|
echo "The locations above may contain strings resembling sensitive information."
|
|
263
295
|
echo "Please review the content before committing, and remove or replace it if needed."
|
|
264
296
|
echo "If this detection is not an issue, bypass it with: git commit --no-verify"
|
|
297
|
+
# Show where this check comes from (the absolute path of this hook). git passes
|
|
298
|
+
# $0 as a relative path in the main worktree and an absolute path in linked
|
|
299
|
+
# worktrees, so make it absolute without spawning external commands.
|
|
300
|
+
hook_path=$0
|
|
301
|
+
case $hook_path in /*|[A-Za-z]:[\\/]*) ;; *) hook_path=$PWD/${hook_path#./} ;; esac
|
|
302
|
+
sanitize_display "$hook_path"
|
|
303
|
+
echo "This check comes from the pre-commit hook placed by accel CLI ($display_text)."
|
|
265
304
|
exit 1
|
|
266
305
|
fi
|
|
267
306
|
|
|
@@ -2,16 +2,51 @@
|
|
|
2
2
|
# @accel-cli-managed
|
|
3
3
|
#
|
|
4
4
|
# pre-commit:
|
|
5
|
-
# git
|
|
6
|
-
#
|
|
5
|
+
# git にステージされた変更内容に、機密情報に類似した文字列が含まれていないかを
|
|
6
|
+
# 検査し、検出時はコミットをブロックするフックスクリプト。
|
|
7
7
|
#
|
|
8
8
|
# 有効化方法:
|
|
9
|
-
#
|
|
10
|
-
#
|
|
9
|
+
# accel CLI が接続情報の保存時(accel login など)に配置します
|
|
10
|
+
# (通常は .git/hooks/pre-commit)。
|
|
11
|
+
# 手動で使う場合は、既存の pre-commit フックから実行するか
|
|
12
|
+
# (例: bash <このファイルのパス> || exit 1)、
|
|
13
|
+
# .git/hooks/pre-commit としてコピーして実行権限を付けてください。
|
|
11
14
|
#
|
|
12
15
|
set -euo pipefail
|
|
13
16
|
shopt -s nocasematch
|
|
14
17
|
|
|
18
|
+
# git がフックへ引き継ぐ pathspec の解釈の指定(git --literal-pathspecs commit など)は、
|
|
19
|
+
# 下の git diff の対象の絞り込みを変えてしまうため外す。GIT_DIFF_OPTS も、検出した行の
|
|
20
|
+
# 番号がずれるため外す。
|
|
21
|
+
unset GIT_LITERAL_PATHSPECS GIT_GLOB_PATHSPECS GIT_NOGLOB_PATHSPECS GIT_DIFF_OPTS
|
|
22
|
+
|
|
23
|
+
# =============================================================================
|
|
24
|
+
# 表示する名前から制御文字を除く
|
|
25
|
+
# =============================================================================
|
|
26
|
+
|
|
27
|
+
# 端末の制御に使われる文字(C0・DEL・C1)。git は C0 を含むパスを引用符付きで出すが、
|
|
28
|
+
# core.quotePath=false では C1(UTF-8 の U+0080〜U+009F)をそのまま出す。また、このフックの
|
|
29
|
+
# パス($0 と $PWD から作る)には何でも入り得る。CLI の表示と同じく、表示する前に取り除く。
|
|
30
|
+
CONTROL_CHARS=(
|
|
31
|
+
$'\x01' $'\x02' $'\x03' $'\x04' $'\x05' $'\x06' $'\x07' $'\x08'
|
|
32
|
+
$'\x09' $'\x0a' $'\x0b' $'\x0c' $'\x0d' $'\x0e' $'\x0f' $'\x10'
|
|
33
|
+
$'\x11' $'\x12' $'\x13' $'\x14' $'\x15' $'\x16' $'\x17' $'\x18'
|
|
34
|
+
$'\x19' $'\x1a' $'\x1b' $'\x1c' $'\x1d' $'\x1e' $'\x1f' $'\x7f'
|
|
35
|
+
$'\xc2\x80' $'\xc2\x81' $'\xc2\x82' $'\xc2\x83' $'\xc2\x84' $'\xc2\x85' $'\xc2\x86' $'\xc2\x87'
|
|
36
|
+
$'\xc2\x88' $'\xc2\x89' $'\xc2\x8a' $'\xc2\x8b' $'\xc2\x8c' $'\xc2\x8d' $'\xc2\x8e' $'\xc2\x8f'
|
|
37
|
+
$'\xc2\x90' $'\xc2\x91' $'\xc2\x92' $'\xc2\x93' $'\xc2\x94' $'\xc2\x95' $'\xc2\x96' $'\xc2\x97'
|
|
38
|
+
$'\xc2\x98' $'\xc2\x99' $'\xc2\x9a' $'\xc2\x9b' $'\xc2\x9c' $'\xc2\x9d' $'\xc2\x9e' $'\xc2\x9f'
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# $1 から CONTROL_CHARS を取り除いた文字列を display_text に入れる(サブシェルを使わない)。
|
|
42
|
+
sanitize_display() {
|
|
43
|
+
display_text=$1
|
|
44
|
+
local c
|
|
45
|
+
for c in "${CONTROL_CHARS[@]}"; do
|
|
46
|
+
display_text=${display_text//"$c"/}
|
|
47
|
+
done
|
|
48
|
+
}
|
|
49
|
+
|
|
15
50
|
# =============================================================================
|
|
16
51
|
# 変更内容の差分を取得
|
|
17
52
|
# =============================================================================
|
|
@@ -19,7 +54,15 @@ shopt -s nocasematch
|
|
|
19
54
|
# ファイル数分 git diff を呼ぶと大量ファイル変更時に著しく遅くなるため、差分取得は 1回にまとめる。
|
|
20
55
|
# 検出対象は以下に限定するため、git diff の対象ファイルをあらかじめ絞り込む。
|
|
21
56
|
# - intra-mart OAuth クライアントキーが記載される mcp 設定ファイル(.json / .toml)
|
|
22
|
-
|
|
57
|
+
# - package-lock.json は大量のハッシュ文字列が認証キーと誤認されやすいため除外する
|
|
58
|
+
# core.quotePath=false は、非 ASCII のパスを引用符付きの形("a/\346...")で出させないため。
|
|
59
|
+
# 対象のファイルはここで絞り込み済みなので、後でファイル名を解析できなくても検査から外さない。
|
|
60
|
+
# ユーザーの設定(外部 diff・textconv・diff の接頭辞・変更の間に入れる文脈の行数)に左右されずに、
|
|
61
|
+
# ステージした内容そのものを検査し、正しい行番号を示すため、--no-ext-diff --no-textconv
|
|
62
|
+
# --inter-hunk-context=0 と接頭辞を指定する。git がバイナリとして扱うファイル
|
|
63
|
+
# (.gitattributes の -diff / binary など)は検査しない(大きな生成 JSON でコミットが遅くならないように)。
|
|
64
|
+
# シンボリックリンクから通常ファイルへの種類の変更(T)も対象にする。
|
|
65
|
+
diff_output=$(git -c core.quotePath=false diff --cached --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ -U0 --inter-hunk-context=0 --no-color --diff-filter=ACMRT -- '*.json' '*.toml' ':(exclude,glob)**/package-lock.json' 2>/dev/null | tr -d '\0' || true)
|
|
23
66
|
if [ -z "$diff_output" ]; then
|
|
24
67
|
exit 0
|
|
25
68
|
fi
|
|
@@ -173,7 +216,8 @@ check_base64_tokens() {
|
|
|
173
216
|
fi
|
|
174
217
|
|
|
175
218
|
if (( is_match == 0 )); then
|
|
176
|
-
|
|
219
|
+
sanitize_display "$file"
|
|
220
|
+
findings+=("[$display_text:$lineno] intra-mart OAuth クライアントキー文字列を検出しました: ${token:0:12}...")
|
|
177
221
|
found=1
|
|
178
222
|
fi
|
|
179
223
|
done
|
|
@@ -183,18 +227,12 @@ check_base64_tokens() {
|
|
|
183
227
|
# 差分の各行をチェック
|
|
184
228
|
# =============================================================================
|
|
185
229
|
|
|
186
|
-
# 検出対象は以下に限定するため、一部の拡張子のみを対象とする。
|
|
187
|
-
# - intra-mart OAuth クライアントキーが記載される mcp 設定ファイル(.json / .toml)
|
|
188
|
-
INCLUDE_FILE_RE='\.(json|toml)$'
|
|
189
|
-
|
|
190
|
-
# package-lock.json は大量のハッシュ文字列が認証キーと誤認されやすいため、
|
|
191
|
-
# スキャン対象から除外する。
|
|
192
|
-
EXCLUDE_FILE_RE='(^|/)package-lock\.json$'
|
|
193
|
-
|
|
194
230
|
current_file=""
|
|
195
231
|
current_line=0
|
|
196
|
-
|
|
197
|
-
|
|
232
|
+
# 差分のハンク(@@ の行から始まる変更の塊)の中かどうか。ファイルの見出し(--- a/…、+++ b/…)は、
|
|
233
|
+
# 各ファイルの最初のハンクより前にある。内容が "++ " で始まる追加行も "+++ " で始まるので、
|
|
234
|
+
# 文字ではなく位置で区別する。
|
|
235
|
+
in_hunk=0
|
|
198
236
|
|
|
199
237
|
while IFS= read -r line; do
|
|
200
238
|
case "$line" in
|
|
@@ -202,32 +240,22 @@ while IFS= read -r line; do
|
|
|
202
240
|
# 例: diff --git a/path/to/file b/path/to/file
|
|
203
241
|
current_file="${line#diff --git a/}"
|
|
204
242
|
current_file="${current_file%% b/*}"
|
|
205
|
-
|
|
206
|
-
if [[ "$current_file" =~ $INCLUDE_FILE_RE ]] && [[ ! "$current_file" =~ $EXCLUDE_FILE_RE ]]; then
|
|
207
|
-
skip_file=0
|
|
208
|
-
else
|
|
209
|
-
skip_file=1
|
|
210
|
-
fi
|
|
211
|
-
;;
|
|
212
|
-
"Binary files "*|"GIT binary patch"*)
|
|
213
|
-
is_binary=1
|
|
243
|
+
in_hunk=0
|
|
214
244
|
;;
|
|
215
245
|
"@@ "*)
|
|
216
246
|
# 例: @@ -12,0 +13,2 @@ ... → 新ファイル側の開始行番号 (13) を取得する
|
|
217
247
|
if [[ "$line" =~ \+([0-9]+) ]]; then
|
|
218
248
|
current_line="${BASH_REMATCH[1]}"
|
|
219
249
|
fi
|
|
220
|
-
|
|
221
|
-
"+++ "*|"--- "*)
|
|
222
|
-
: # diff ヘッダ行は無視
|
|
250
|
+
in_hunk=1
|
|
223
251
|
;;
|
|
224
252
|
"+"*)
|
|
225
|
-
|
|
226
|
-
|
|
253
|
+
# 追加行はハンクの中にある。ハンクの外で "+" から始まる行は、ファイルの見出し
|
|
254
|
+
if [ "$in_hunk" -eq 1 ]; then
|
|
255
|
+
content="${line#+}"
|
|
256
|
+
check_base64_tokens "$current_file" "$current_line" "$content"
|
|
257
|
+
current_line=$((current_line + 1))
|
|
227
258
|
fi
|
|
228
|
-
content="${line#+}"
|
|
229
|
-
check_base64_tokens "$current_file" "$current_line" "$content"
|
|
230
|
-
current_line=$((current_line + 1))
|
|
231
259
|
;;
|
|
232
260
|
*)
|
|
233
261
|
: ;;
|
|
@@ -249,6 +277,12 @@ if [ "$found" -eq 1 ]; then
|
|
|
249
277
|
echo "上記の箇所に、機密情報に類似する文字列が含まれている可能性があります。"
|
|
250
278
|
echo "コミット前に必ず内容を確認し、必要に応じて削除するか、他の文字列に置き換えてください。"
|
|
251
279
|
echo "検出内容に問題がない場合は、git commit --no-verify で回避してください。"
|
|
280
|
+
# 出どころ(このフックの絶対パス)を示す。git は $0 を本体では相対パス、
|
|
281
|
+
# worktree では絶対パスで渡すため、外部コマンドを使わずに絶対パスへ直す
|
|
282
|
+
hook_path=$0
|
|
283
|
+
case $hook_path in /*|[A-Za-z]:[\\/]*) ;; *) hook_path=$PWD/${hook_path#./} ;; esac
|
|
284
|
+
sanitize_display "$hook_path"
|
|
285
|
+
echo "このチェックは accel CLI が配置した pre-commit フック($display_text)によるものです。"
|
|
252
286
|
exit 1
|
|
253
287
|
fi
|
|
254
288
|
|
|
@@ -3,15 +3,50 @@
|
|
|
3
3
|
#
|
|
4
4
|
# pre-commit:
|
|
5
5
|
# 扫描已暂存到 git 的变更内容中是否包含疑似敏感信息的字符串,
|
|
6
|
-
#
|
|
6
|
+
# 若检测到则阻止本次提交的钩子脚本。
|
|
7
7
|
#
|
|
8
8
|
# 启用方法:
|
|
9
|
-
#
|
|
10
|
-
#
|
|
9
|
+
# accel CLI 会在保存连接信息时(如 accel login)部署此钩子
|
|
10
|
+
# (通常为 .git/hooks/pre-commit)。
|
|
11
|
+
# 如需手动使用,请从现有的 pre-commit 钩子中执行本文件
|
|
12
|
+
# (例如:bash <本文件路径> || exit 1),
|
|
13
|
+
# 或将其复制为 .git/hooks/pre-commit 并赋予执行权限。
|
|
11
14
|
#
|
|
12
15
|
set -euo pipefail
|
|
13
16
|
shopt -s nocasematch
|
|
14
17
|
|
|
18
|
+
# git 传递给钩子的 pathspec 解释方式(如 git --literal-pathspecs commit)
|
|
19
|
+
# 会改变下面 git diff 的筛选结果,因此将其清除。GIT_DIFF_OPTS 会使显示的行号
|
|
20
|
+
# 发生偏移,因此也一并清除。
|
|
21
|
+
unset GIT_LITERAL_PATHSPECS GIT_GLOB_PATHSPECS GIT_NOGLOB_PATHSPECS GIT_DIFF_OPTS
|
|
22
|
+
|
|
23
|
+
# =============================================================================
|
|
24
|
+
# 从显示的名称中移除控制字符
|
|
25
|
+
# =============================================================================
|
|
26
|
+
|
|
27
|
+
# 用于控制终端的字符(C0、DEL、C1)。git 会对包含 C0 的路径加引号输出,但在
|
|
28
|
+
# core.quotePath=false 时会原样输出 C1(UTF-8 中的 U+0080~U+009F),且本钩子的
|
|
29
|
+
# 路径(由 $0 和 $PWD 生成)可能包含任意字符。与 CLI 的显示一样,在显示前将其移除。
|
|
30
|
+
CONTROL_CHARS=(
|
|
31
|
+
$'\x01' $'\x02' $'\x03' $'\x04' $'\x05' $'\x06' $'\x07' $'\x08'
|
|
32
|
+
$'\x09' $'\x0a' $'\x0b' $'\x0c' $'\x0d' $'\x0e' $'\x0f' $'\x10'
|
|
33
|
+
$'\x11' $'\x12' $'\x13' $'\x14' $'\x15' $'\x16' $'\x17' $'\x18'
|
|
34
|
+
$'\x19' $'\x1a' $'\x1b' $'\x1c' $'\x1d' $'\x1e' $'\x1f' $'\x7f'
|
|
35
|
+
$'\xc2\x80' $'\xc2\x81' $'\xc2\x82' $'\xc2\x83' $'\xc2\x84' $'\xc2\x85' $'\xc2\x86' $'\xc2\x87'
|
|
36
|
+
$'\xc2\x88' $'\xc2\x89' $'\xc2\x8a' $'\xc2\x8b' $'\xc2\x8c' $'\xc2\x8d' $'\xc2\x8e' $'\xc2\x8f'
|
|
37
|
+
$'\xc2\x90' $'\xc2\x91' $'\xc2\x92' $'\xc2\x93' $'\xc2\x94' $'\xc2\x95' $'\xc2\x96' $'\xc2\x97'
|
|
38
|
+
$'\xc2\x98' $'\xc2\x99' $'\xc2\x9a' $'\xc2\x9b' $'\xc2\x9c' $'\xc2\x9d' $'\xc2\x9e' $'\xc2\x9f'
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# 将从 $1 中移除 CONTROL_CHARS 后的字符串存入 display_text(不使用子 shell)。
|
|
42
|
+
sanitize_display() {
|
|
43
|
+
display_text=$1
|
|
44
|
+
local c
|
|
45
|
+
for c in "${CONTROL_CHARS[@]}"; do
|
|
46
|
+
display_text=${display_text//"$c"/}
|
|
47
|
+
done
|
|
48
|
+
}
|
|
49
|
+
|
|
15
50
|
# =============================================================================
|
|
16
51
|
# 获取变更差异
|
|
17
52
|
# =============================================================================
|
|
@@ -20,7 +55,15 @@ shopt -s nocasematch
|
|
|
20
55
|
# 因此差异获取统一合并为 1 次。
|
|
21
56
|
# 由于检测范围仅限于以下内容,因此通过 git 的路径规格预先筛选目标文件:
|
|
22
57
|
# - 记载 intra-mart OAuth 客户端密钥的 mcp 配置文件(.json / .toml)
|
|
23
|
-
|
|
58
|
+
# - package-lock.json 中包含大量容易被误判为认证密钥的哈希类字符串,因此排除
|
|
59
|
+
# core.quotePath=false 用于避免 git 以带引号的形式("a/\346...")输出非 ASCII 路径。
|
|
60
|
+
# 检测对象已在此处筛选,因此即使之后无法解析文件名,也不会将其排除在检查之外。
|
|
61
|
+
# 为了不受用户设置(外部 diff、textconv、diff 前缀、变更之间插入的上下文行数)的影响,直接检查
|
|
62
|
+
# 暂存的内容本身并显示正确的行号,这里指定 --no-ext-diff --no-textconv --inter-hunk-context=0
|
|
63
|
+
# 以及前缀。git 视为二进制的文件
|
|
64
|
+
# (.gitattributes 的 -diff / binary 等)不做检查(避免大型生成 JSON 导致提交变慢)。
|
|
65
|
+
# 从符号链接变为普通文件的类型变更(T)也纳入检查对象。
|
|
66
|
+
diff_output=$(git -c core.quotePath=false diff --cached --no-ext-diff --no-textconv --src-prefix=a/ --dst-prefix=b/ -U0 --inter-hunk-context=0 --no-color --diff-filter=ACMRT -- '*.json' '*.toml' ':(exclude,glob)**/package-lock.json' 2>/dev/null | tr -d '\0' || true)
|
|
24
67
|
if [ -z "$diff_output" ]; then
|
|
25
68
|
exit 0
|
|
26
69
|
fi
|
|
@@ -173,7 +216,8 @@ check_base64_tokens() {
|
|
|
173
216
|
fi
|
|
174
217
|
|
|
175
218
|
if (( is_match == 0 )); then
|
|
176
|
-
|
|
219
|
+
sanitize_display "$file"
|
|
220
|
+
findings+=("[$display_text:$lineno] 检测到 intra-mart OAuth 客户端密钥字符串: ${token:0:12}...")
|
|
177
221
|
found=1
|
|
178
222
|
fi
|
|
179
223
|
done
|
|
@@ -183,18 +227,12 @@ check_base64_tokens() {
|
|
|
183
227
|
# 检查差异中的每一行
|
|
184
228
|
# =============================================================================
|
|
185
229
|
|
|
186
|
-
# 由于检测范围仅限于以下内容,因此仅将下述扩展名作为检测对象。
|
|
187
|
-
# - 记载 intra-mart OAuth 客户端密钥的 mcp 配置文件(.json / .toml)
|
|
188
|
-
INCLUDE_FILE_RE='\.(json|toml)$'
|
|
189
|
-
|
|
190
|
-
# package-lock.json 中包含大量容易被误判为认证密钥的哈希类字符串,
|
|
191
|
-
# 因此从扫描对象中排除。
|
|
192
|
-
EXCLUDE_FILE_RE='(^|/)package-lock\.json$'
|
|
193
|
-
|
|
194
230
|
current_file=""
|
|
195
231
|
current_line=0
|
|
196
|
-
|
|
197
|
-
|
|
232
|
+
# 是否位于差异的 hunk(以 @@ 行开始的变更块)之中。文件头(--- a/…、+++ b/…)位于
|
|
233
|
+
# 每个文件的第一个 hunk 之前。内容以 "++ " 开头的新增行也以 "+++ " 开头,
|
|
234
|
+
# 因此按位置而不是按文字区分。
|
|
235
|
+
in_hunk=0
|
|
198
236
|
|
|
199
237
|
while IFS= read -r line; do
|
|
200
238
|
case "$line" in
|
|
@@ -202,32 +240,22 @@ while IFS= read -r line; do
|
|
|
202
240
|
# 例如: diff --git a/path/to/file b/path/to/file
|
|
203
241
|
current_file="${line#diff --git a/}"
|
|
204
242
|
current_file="${current_file%% b/*}"
|
|
205
|
-
|
|
206
|
-
if [[ "$current_file" =~ $INCLUDE_FILE_RE ]] && [[ ! "$current_file" =~ $EXCLUDE_FILE_RE ]]; then
|
|
207
|
-
skip_file=0
|
|
208
|
-
else
|
|
209
|
-
skip_file=1
|
|
210
|
-
fi
|
|
211
|
-
;;
|
|
212
|
-
"Binary files "*|"GIT binary patch"*)
|
|
213
|
-
is_binary=1
|
|
243
|
+
in_hunk=0
|
|
214
244
|
;;
|
|
215
245
|
"@@ "*)
|
|
216
246
|
# 例如: @@ -12,0 +13,2 @@ ... → 获取新文件一侧的起始行号(13)
|
|
217
247
|
if [[ "$line" =~ \+([0-9]+) ]]; then
|
|
218
248
|
current_line="${BASH_REMATCH[1]}"
|
|
219
249
|
fi
|
|
220
|
-
|
|
221
|
-
"+++ "*|"--- "*)
|
|
222
|
-
: # 忽略 diff 头部行
|
|
250
|
+
in_hunk=1
|
|
223
251
|
;;
|
|
224
252
|
"+"*)
|
|
225
|
-
|
|
226
|
-
|
|
253
|
+
# 新增行位于 hunk 之中。hunk 之外以 "+" 开头的行是文件头
|
|
254
|
+
if [ "$in_hunk" -eq 1 ]; then
|
|
255
|
+
content="${line#+}"
|
|
256
|
+
check_base64_tokens "$current_file" "$current_line" "$content"
|
|
257
|
+
current_line=$((current_line + 1))
|
|
227
258
|
fi
|
|
228
|
-
content="${line#+}"
|
|
229
|
-
check_base64_tokens "$current_file" "$current_line" "$content"
|
|
230
|
-
current_line=$((current_line + 1))
|
|
231
259
|
;;
|
|
232
260
|
*)
|
|
233
261
|
: ;;
|
|
@@ -249,6 +277,12 @@ if [ "$found" -eq 1 ]; then
|
|
|
249
277
|
echo "以上位置可能包含疑似敏感信息的字符串。"
|
|
250
278
|
echo "请在提交前务必确认内容,并按需删除或替换为其他字符串。"
|
|
251
279
|
echo "如确认检测内容没有问题,可使用 git commit --no-verify 跳过本次检查。"
|
|
280
|
+
# 显示检查的来源(此钩子的绝对路径)。git 在主工作区以相对路径、
|
|
281
|
+
# 在 worktree 中以绝对路径传递 $0,因此不使用外部命令将其转换为绝对路径
|
|
282
|
+
hook_path=$0
|
|
283
|
+
case $hook_path in /*|[A-Za-z]:[\\/]*) ;; *) hook_path=$PWD/${hook_path#./} ;; esac
|
|
284
|
+
sanitize_display "$hook_path"
|
|
285
|
+
echo "此检查来自 accel CLI 部署的 pre-commit 钩子($display_text)。"
|
|
252
286
|
exit 1
|
|
253
287
|
fi
|
|
254
288
|
|
|
@@ -112,13 +112,13 @@ export const MESSAGES = {
|
|
|
112
112
|
"cause.linkBlocked": "原因: {path} にリンク以外のディレクトリまたはファイルが存在します。",
|
|
113
113
|
"remedy.linkBlocked":
|
|
114
114
|
"対処: {path} にある既存のディレクトリ・ファイルには触れません。リンクに置き換える場合は {path} を削除してから再実行してください。",
|
|
115
|
-
|
|
115
|
+
"cause.unsafeLayout": "原因: {path} がシンボリックリンクです(CLI が作るディレクトリではありません)。",
|
|
116
116
|
"remedy.unsafeLayout":
|
|
117
117
|
"対処: {path} を削除してから再実行してください。",
|
|
118
118
|
"cause.unsafePath": "原因: 依存ディレクトリ {dir} がプロジェクトの外を指しています。",
|
|
119
119
|
"remedy.unsafePath":
|
|
120
120
|
"対処: {dir} のシンボリックリンクを外してから再実行してください。",
|
|
121
|
-
"cause.lockTimeout": "原因: 別のプロセスが {dir} の依存を準備中のまま、待ち時間内に完了しませんでした。",
|
|
121
|
+
"cause.lockTimeout": "原因: 別のプロセスが {dir} の依存を準備中のまま、待ち時間内に完了しませんでした。",
|
|
122
122
|
"remedy.lockTimeout":
|
|
123
123
|
"対処: しばらく待ってから再実行してください。止まったままなら .accel/runtime/{id}.lock を削除してから再実行してください。",
|
|
124
124
|
"cause.installFailed":
|
|
@@ -130,7 +130,7 @@ export const MESSAGES = {
|
|
|
130
130
|
},
|
|
131
131
|
en: {
|
|
132
132
|
installed: "Installed skill dependencies: {dir} (id: {id})",
|
|
133
|
-
summary: "Failed to prepare skill dependencies ({count}
|
|
133
|
+
summary: "Failed to prepare skill dependencies ({count} problem(s)).",
|
|
134
134
|
"cause.conflict":
|
|
135
135
|
"Cause: package.json / lockfile in {dir} still contain unresolved conflict markers (an update conflict has not been resolved).",
|
|
136
136
|
"remedy.conflict": "Remedy: resolve the conflict in {dir}, then rerun.",
|
|
@@ -150,11 +150,11 @@ export const MESSAGES = {
|
|
|
150
150
|
"cause.linkBlocked": "Cause: {path} is a directory or file, not a link.",
|
|
151
151
|
"remedy.linkBlocked":
|
|
152
152
|
"Remedy: the existing directory or file at {path} is left untouched. To replace it with a link, delete {path}, then rerun.",
|
|
153
|
-
|
|
153
|
+
"cause.unsafeLayout": "Cause: {path} is a symbolic link (not a directory created by the CLI).",
|
|
154
154
|
"remedy.unsafeLayout": "Remedy: delete {path}, then rerun.",
|
|
155
155
|
"cause.unsafePath": "Cause: the dependency directory {dir} points outside the project.",
|
|
156
156
|
"remedy.unsafePath": "Remedy: remove the symbolic link at {dir}, then rerun.",
|
|
157
|
-
"cause.lockTimeout": "Cause: another process is still preparing the dependencies in {dir} and did not finish within the wait time.",
|
|
157
|
+
"cause.lockTimeout": "Cause: another process is still preparing the dependencies in {dir} and did not finish within the wait time.",
|
|
158
158
|
"remedy.lockTimeout":
|
|
159
159
|
"Remedy: wait a moment and rerun. If it stays stuck, delete .accel/runtime/{id}.lock, then rerun.",
|
|
160
160
|
"cause.installFailed":
|
|
@@ -185,11 +185,11 @@ export const MESSAGES = {
|
|
|
185
185
|
"cause.linkBlocked": "原因: {path} 处存在非链接的目录或文件。",
|
|
186
186
|
"remedy.linkBlocked":
|
|
187
187
|
"处理: 不会触碰 {path} 处现有的目录或文件。如需替换为链接,请删除 {path} 后重新执行。",
|
|
188
|
-
|
|
188
|
+
"cause.unsafeLayout": "原因: {path} 是符号链接(不是 CLI 创建的目录)。",
|
|
189
189
|
"remedy.unsafeLayout": "处理: 请删除 {path} 后重新执行。",
|
|
190
190
|
"cause.unsafePath": "原因: 依赖目录 {dir} 指向了项目之外。",
|
|
191
191
|
"remedy.unsafePath": "处理: 请移除 {dir} 处的符号链接后重新执行。",
|
|
192
|
-
"cause.lockTimeout": "原因: 另一个进程仍在准备 {dir} 的依赖,且未在等待时间内完成。",
|
|
192
|
+
"cause.lockTimeout": "原因: 另一个进程仍在准备 {dir} 的依赖,且未在等待时间内完成。",
|
|
193
193
|
"remedy.lockTimeout":
|
|
194
194
|
"处理: 请稍候再重新执行。如果一直停滞,请删除 .accel/runtime/{id}.lock 后重新执行。",
|
|
195
195
|
"cause.installFailed": "原因: install 命令执行失败。命令: {command} / 工作目录: {cwd}",
|
|
@@ -833,19 +833,30 @@ export function ensure(root, settings) {
|
|
|
833
833
|
// 出力
|
|
834
834
|
// =============================================================================
|
|
835
835
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
836
|
+
/**
|
|
837
|
+
* 失敗の案内を組み立てる。原因・対処・出力の末尾がすべて同じ案内は 1 回だけ出し
|
|
838
|
+
* (パッケージマネージャが見つからない場合など、文に依存ディレクトリが入らない原因で
|
|
839
|
+
* 同じ文を繰り返さない)、要約の件数は出した案内の数とする。
|
|
840
|
+
*/
|
|
841
|
+
export function formatGuidance(locale, failures) {
|
|
842
|
+
const blocks = [];
|
|
843
|
+
for (const failure of failures) {
|
|
844
|
+
const lines = [
|
|
845
|
+
t(locale, `cause.${failure.kind}`, failure.params),
|
|
846
|
+
t(locale, `remedy.${failure.kind}`, failure.params),
|
|
847
|
+
];
|
|
842
848
|
if (failure.tail && failure.tail.length > 0) {
|
|
843
849
|
lines.push(t(locale, "outputTail"));
|
|
844
850
|
for (const line of failure.tail) lines.push(` ${cleanText(line)}`);
|
|
845
851
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
852
|
+
const block = lines.join("\n");
|
|
853
|
+
if (!blocks.includes(block)) blocks.push(block);
|
|
854
|
+
}
|
|
855
|
+
return `${[
|
|
856
|
+
t(locale, "summary", { count: blocks.length }),
|
|
857
|
+
blocks.join("\n\n"),
|
|
858
|
+
t(locale, "rerun", { command: RERUN_COMMAND }),
|
|
859
|
+
].join("\n")}\n`;
|
|
849
860
|
}
|
|
850
861
|
|
|
851
862
|
// =============================================================================
|
package/dist/asset/deployer.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AssetProvider, AccelSettings, HashsumEntry } from "../core/types.js";
|
|
2
2
|
import { type AssetMessage } from "./messages.js";
|
|
3
|
-
export { getInstallCmds } from "./installer.js";
|
|
4
3
|
export type OverwriteDecision = "overwrite" | "skip";
|
|
5
4
|
export type ExistingFileHandler = (relativePath: string) => Promise<OverwriteDecision>;
|
|
6
5
|
export type ProgressCallbacks = {
|
|
@@ -16,7 +15,6 @@ export type DeployOptions = {
|
|
|
16
15
|
projectDir: string;
|
|
17
16
|
settings: AccelSettings;
|
|
18
17
|
provider: AssetProvider;
|
|
19
|
-
noInstall: boolean;
|
|
20
18
|
skipExistingFiles?: boolean;
|
|
21
19
|
onExistingFile?: ExistingFileHandler;
|
|
22
20
|
progress?: ProgressCallbacks;
|