@cocorograph/hub-agent 0.6.69 → 0.6.70
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 +1 -1
- package/src/claude-md.mjs +31 -7
package/package.json
CHANGED
package/src/claude-md.mjs
CHANGED
|
@@ -82,6 +82,18 @@ async function fetchRepositories({ hubUrl, accessToken, dirName, fetchImpl }) {
|
|
|
82
82
|
*
|
|
83
83
|
* リポジトリが 1 件もない場合は空文字列を返し、CLAUDE.md には何も追記しない。
|
|
84
84
|
*/
|
|
85
|
+
/**
|
|
86
|
+
* repo_url が GitHub の `owner/repo` slug 形式かを判定する。
|
|
87
|
+
*
|
|
88
|
+
* `://` や `@` を含むフル URL(GitLab の `git@gitlab.com:...` や
|
|
89
|
+
* `https://gitlab.com/...` 等)は false を返す。これらは `gh` ではなく
|
|
90
|
+
* 素の `git clone` でチェックアウトする。
|
|
91
|
+
*/
|
|
92
|
+
function isGitHubSlug(repoUrl) {
|
|
93
|
+
if (/:\/\/|@/.test(repoUrl)) return false
|
|
94
|
+
return /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repoUrl)
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
function renderRepositorySection(repositories, dirName = "") {
|
|
86
98
|
if (!Array.isArray(repositories) || repositories.length === 0) return ""
|
|
87
99
|
|
|
@@ -113,16 +125,28 @@ function renderRepositorySection(repositories, dirName = "") {
|
|
|
113
125
|
if (productionName) lines.push(`- **本番**: ${productionName}`)
|
|
114
126
|
lines.push("")
|
|
115
127
|
|
|
128
|
+
const githubSlug = isGitHubSlug(repoUrl)
|
|
116
129
|
lines.push("**作業手順(クローンレス)**:")
|
|
117
130
|
lines.push("")
|
|
118
131
|
lines.push("```bash")
|
|
119
132
|
lines.push("TMPDIR=$(mktemp -d)")
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
if (githubSlug) {
|
|
134
|
+
// GitHub: gh CLI で clone・PR 作成
|
|
135
|
+
lines.push(`gh repo clone ${repoUrl} "$TMPDIR" -- --depth 1 --filter=blob:none --no-checkout`)
|
|
136
|
+
lines.push(`cd "$TMPDIR" && git fetch origin ${branch} && git checkout -b feat/<your-change> origin/${branch}`)
|
|
137
|
+
lines.push("# ファイル編集 → 動作確認")
|
|
138
|
+
lines.push('git commit -am "<message>"')
|
|
139
|
+
lines.push("git push -u origin HEAD")
|
|
140
|
+
lines.push(`gh pr create --base ${branch} --fill`)
|
|
141
|
+
} else {
|
|
142
|
+
// GitLab 等: 素の git clone。MR は push 後に Web/glab で作成
|
|
143
|
+
lines.push(`git clone --depth 1 --filter=blob:none --no-checkout ${repoUrl} "$TMPDIR"`)
|
|
144
|
+
lines.push(`cd "$TMPDIR" && git fetch origin ${branch} && git checkout -b feat/<your-change> origin/${branch}`)
|
|
145
|
+
lines.push("# ファイル編集 → 動作確認")
|
|
146
|
+
lines.push('git commit -am "<message>"')
|
|
147
|
+
lines.push("git push -u origin HEAD")
|
|
148
|
+
lines.push("# MR は GitLab の Web UI(push 時に表示される URL)か `glab mr create` で作成")
|
|
149
|
+
}
|
|
126
150
|
lines.push("# 作業終了後")
|
|
127
151
|
lines.push('cd / && rm -rf "$TMPDIR"')
|
|
128
152
|
lines.push("```")
|
|
@@ -165,7 +189,7 @@ function renderRepositorySection(repositories, dirName = "") {
|
|
|
165
189
|
"- **本番反映の前に必ず現状バックアップを取る**(DB ダンプ / 対象ディレクトリの退避)。",
|
|
166
190
|
"- ステージングで動作確認してから本番へ。",
|
|
167
191
|
"- 破壊的操作(`reset --hard` / `rm -rf` / DB 操作)の前に対象を確認する。",
|
|
168
|
-
"- Git 認証はローカルの `gh` CLI
|
|
192
|
+
"- Git 認証はローカルの `gh` CLI(GitHub)/ SSH 鍵(GitLab 等)を使用します。",
|
|
169
193
|
"",
|
|
170
194
|
)
|
|
171
195
|
return lines.join("\n")
|