tazuna 0.16.0 → 0.18.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/README.md CHANGED
@@ -15,8 +15,10 @@ tazuna では AI はあなたの PC に一切触れません。コードを渡
15
15
  `.tazuna/history/` に自動保存される
16
16
  3. **直す** (`tazuna build`): MSBuild でビルドし、失敗したらエラーと今のファイルの周辺行をクリップボードへ入れる
17
17
 
18
- レガシー VB.NET (`.sln` / `.vbproj`、Shift_JIS) を出発点にしていますが、TypeScript・Python・C#・Go などの
19
- プロジェクトでも使えます (git が管理しているファイルをまとめる)。実行時依存はゼロで、通信もしません
18
+ レガシー VB.NET (`.sln` / `.vbproj`、Shift_JIS) を出発点にしていますが、C# の `.csproj` も同じように
19
+ `.sln` の構成で扱えます (0.17.0。旧スタイル / SDK スタイル、WinForms の Designer.cs の要約)。TypeScript・Python・
20
+ Go・Java・PHP などのプロジェクトでも使えます (git が管理しているファイルをまとめる。`tazuna init` が拡張子を見て
21
+ 入れる種類を設定に書き、vendor・生成コード・鍵・データのファイルは入れない。0.18.0)。実行時依存はゼロで、通信もしません
20
22
  (導入審査向けの説明は [docs/SECURITY-REVIEW.md](docs/SECURITY-REVIEW.md))。
21
23
 
22
24
  0.15.0 で、変更を当てる側だった petari と、パックを作る側だった [slnmix](https://www.npmjs.com/package/slnmix) を
@@ -39,7 +41,7 @@ npx tazuna pack # パックを作り、Copilot Chat に貼るものを
39
41
  # → AI から changes.md をダウンロード
40
42
  npx tazuna # Downloads の changes.md を自動検出して適用
41
43
  git diff # VS Code で差分レビュー・手修正
42
- npx tazuna build # (VB.NET) ビルドし、失敗ならエラーと周辺のコードをクリップボードへ → チャットに貼る
44
+ npx tazuna build # (VB.NET / C#) ビルドし、失敗ならエラーと周辺のコードをクリップボードへ → チャットに貼る
43
45
  npx tazuna undo # 直近の適用を巻き戻す
44
46
  ```
45
47
 
@@ -86,24 +88,26 @@ RDP 越しに受け渡す運用では従来どおり `tazuna` / `tazuna --clip`
86
88
  - `npx petari` と `npx slnmix` もしばらくは動きます (tazuna を呼ぶだけの互換パッケージ。実行のたびに
87
89
  移行を知らせる 1 行が出ます)
88
90
 
89
- ### レガシー VB.NET プロジェクトでの適用
91
+ ### レガシー VB.NET / C# プロジェクトでの適用
90
92
 
91
- #### 新規 .vb ファイルの作成
93
+ #### 新規 .vb / .cs ファイルの作成
92
94
 
93
- AI が `create` で `.vb` を新規作成すると、tazuna が次を自動で行います (Visual Studio での
95
+ AI が `create` で `.vb` / `.cs` を新規作成すると、tazuna が次を自動で行います (Visual Studio での
94
96
  手作業をなくすため)。いずれも失敗しても create 自体は成功し、理由を結果表示に出します。
95
97
 
96
- - **旧スタイル .vbproj への登録**: 作成先から上へ辿って最寄りの `.vbproj` を探し、
97
- `<Compile Include="...">` を追加します (`Inherits Form` なら `<SubType>Form</SubType>`、
98
- `X.Designer.vb` なら `<DependentUpon>X.vb</DependentUpon>` 付き)。追加行以外のバイト列は
99
- 変えません (Shift_JIS / CRLF / BOM そのまま)。SDK スタイルの `.vbproj` は登録不要のため
98
+ - **旧スタイル .vbproj / .csproj への登録**: 作成先から上へ辿って最寄りのプロジェクトファイルを探し
99
+ (`.vb` は `.vbproj`、`.cs` は `.csproj`。最寄りのプロジェクトが別の言語なら登録しません)、
100
+ `<Compile Include="...">` を追加します (`Inherits Form` / `class X : Form` なら `<SubType>Form</SubType>`、
101
+ `X.Designer.vb` / `X.Designer.cs` なら `<DependentUpon>X.vb</DependentUpon>` などが付きます)。追加行以外のバイト列は
102
+ 変えません (Shift_JIS / CRLF / BOM そのまま)。SDK スタイルのプロジェクトは登録不要のため
100
103
  触りません。登録は履歴に含まれ `tazuna undo` で戻ります。無効化は `--no-vbproj` か
101
104
  `.tazuna/config.json` (旧版から使っているリポジトリでは `.petari/config.json`。以下同じ) の
102
- `"vbproj": { "register": false }`
105
+ `"vbproj": { "register": false }` (名前は vbproj のままで、.csproj への登録も止まります)
103
106
  - **エンコーディングの推定**: `.tazuna/config.json` の `"newFile": { "encoding": "auto" }`
104
107
  (`tazuna init` の雛形の既定) で、同じディレクトリの既存ファイルの多数決で
105
108
  文字コード / BOM / 改行を決めます。`.vb` を BOM なし UTF-8 で作ることはありません
106
- (vbc / VS で日本語が化けるため)。従来どおり `"utf8"` / `"shift_jis"` の明示指定も使えます
109
+ (vbc / VS で日本語が化けるため)。手本が無いときの `.vb` / `.cs` は Visual Studio と同じ UTF-8 (BOM あり) / CRLF です。
110
+ 従来どおり `"utf8"` / `"shift_jis"` の明示指定も使えます
107
111
 
108
112
  ### 適用が繰り返し失敗するとき
109
113
 
@@ -135,7 +139,7 @@ repomix の出力) が実ファイルとずれている**可能性が高いで
135
139
 
136
140
  適用の主なオプション: `--dry-run` (検証と差分プレビューのみ) / `--partial` (成功分のみ適用) /
137
141
  `--root <dir>` / `--yes` / `--clip-report` (失敗レポートをクリップボードへ。v0.5.0 から既定で自動コピーされるため、config で無効化した場合の個別指定用) /
138
- `--no-vbproj` (create した .vb の .vbproj 自動登録を今回だけ無効化) /
142
+ `--no-vbproj` (create した .vb / .cs の .vbproj / .csproj 自動登録を今回だけ無効化) /
139
143
  `--force` (適用済みの changes.md でも再適用する。下記「二重適用の防止」を今回だけ解除) /
140
144
  `--literal-masked` (元の値に戻せない `[MASKED]` をその文字のまま書く。伏せ字を扱うコードそのものを書くとき用。下記「伏せ字 [MASKED] の扱い」)
141
145
 
@@ -12,7 +12,7 @@ import { changeSetFingerprint } from "../core/fingerprint.js";
12
12
  import { PRESENCE_STAGE_LABEL } from "../core/matcher.js";
13
13
  import { fixedNewFile, resolveNewFileStyle } from "../core/new-file-style.js";
14
14
  import { parseChangesRecovering } from "../core/parser.js";
15
- import { buildBlankInsensitiveNote, buildMaskRestoreNote, buildFailureReport, buildParseErrorReport, } from "../core/report.js";
15
+ import { buildBlankInsensitiveNote, buildMaskRestoreNote, buildSjisFoldNote, buildFailureReport, buildParseErrorReport, } from "../core/report.js";
16
16
  import { readClipboard, writeClipboard } from "../infra/clipboard.js";
17
17
  import { loadConfig } from "../infra/config.js";
18
18
  import { findRecentChangesFiles, resolveDownloadsDir, } from "../infra/downloads.js";
@@ -85,7 +85,7 @@ export async function applyCommand(argv, detected) {
85
85
  yes: { type: "boolean", short: "y", default: false },
86
86
  clip: { type: "boolean", default: false },
87
87
  "clip-report": { type: "boolean", default: false },
88
- // create した .vb の .vbproj 自動登録を今回だけ無効化 (config vbproj.register の一時上書き)
88
+ // create した .vb / .cs の .vbproj / .csproj 自動登録を今回だけ無効化 (config vbproj.register の一時上書き)
89
89
  "no-vbproj": { type: "boolean", default: false },
90
90
  // 履歴で適用済みの changes.md でも再適用する (二重適用防止の解除・§6.1)
91
91
  force: { type: "boolean", default: false },
@@ -276,7 +276,7 @@ export async function applyCommand(argv, detected) {
276
276
  return 1;
277
277
  }
278
278
  const applicable = plan.outcomes.filter(isApplicable);
279
- // create した .vb の旧スタイル .vbproj への登録計画 (設計書 §11.1)。失敗しても create は成功扱い
279
+ // create した .vb / .cs の旧スタイル .vbproj / .csproj への登録計画 (設計書 §11.1)。失敗しても create は成功扱い
280
280
  const vbprojEnabled = config.vbproj.register && !values["no-vbproj"];
281
281
  const vbprojPlan = vbprojEnabled
282
282
  ? planVbprojRegistrations(root, applicable)
@@ -334,6 +334,9 @@ export async function applyCommand(argv, detected) {
334
334
  const dryRunMaskNote = buildMaskRestoreNote(plan.outcomes, false);
335
335
  if (dryRunMaskNote !== null)
336
336
  out(dryRunMaskNote);
337
+ const dryRunSjisNote = buildSjisFoldNote(plan.outcomes, false);
338
+ if (dryRunSjisNote !== null)
339
+ out(dryRunSjisNote);
337
340
  if (plan.failures.length > 0) {
338
341
  out("");
339
342
  await emitReport(buildFailureReport(plan.failures, { outcomes: plan.outcomes, nothingWritten: true }));
@@ -461,6 +464,9 @@ export async function applyCommand(argv, detected) {
461
464
  const maskNote = buildMaskRestoreNote(plan.outcomes, true);
462
465
  if (maskNote !== null)
463
466
  out(maskNote);
467
+ const sjisNote = buildSjisFoldNote(plan.outcomes, true);
468
+ if (sjisNote !== null)
469
+ out(sjisNote);
464
470
  if (plan.failures.length > 0) {
465
471
  out(`スキップした失敗 ${plan.failures.length} 件のレポート:`);
466
472
  out("");
@@ -42,7 +42,7 @@ export function buildCommand(argv) {
42
42
  return 1;
43
43
  }
44
44
  if (resolved.targetPath === undefined) {
45
- err(`${BUILD_COMMAND} は .sln / .vbproj の構成でのみ使えます(kind: "generic" のプロジェクトは、そのプロジェクトのビルド・テストのコマンドを使ってください)。`);
45
+ err(`${BUILD_COMMAND} は .sln / .vbproj / .csproj の構成でのみ使えます(kind: "generic" のプロジェクトは、そのプロジェクトのビルド・テストのコマンドを使ってください)。`);
46
46
  return 1;
47
47
  }
48
48
  return runBuild(resolved.targetPath, resolved.rootDir, {
@@ -7,11 +7,12 @@
7
7
  * --yes / --no-repomix は受け付けて無視する (旧 slnmix init が `--yes --no-repomix` で呼んでいたため)。
8
8
  */
9
9
  import * as fs from "node:fs";
10
+ import * as path from "node:path";
10
11
  import { parseArgs } from "node:util";
11
- import { initProject } from "../pack/initProject.js";
12
+ import { GENERATED_OUTPUTS, initProject } from "../pack/initProject.js";
12
13
  import { findProjectRoot } from "../infra/root.js";
13
14
  import { err, out } from "../infra/term.js";
14
- import { FS_DEPS, isDirectoryPath, isFilePath, listDirectoryNames, readSourceTextFile, } from "./pack-io.js";
15
+ import { FS_DEPS, isDirectoryPath, isFilePath, listDirectoryFilesForInit, listDirectoryNames, listPackableGitFiles, readFileHead, readSourceTextFile, } from "./pack-io.js";
15
16
  export async function initCommand(argv) {
16
17
  const { values } = parseArgs({
17
18
  args: argv,
@@ -29,6 +30,9 @@ export async function initCommand(argv) {
29
30
  exists: (p) => fs.existsSync(p),
30
31
  listFileNames: FS_DEPS.listFileNames,
31
32
  listDirectoryNames,
33
+ listPackableGitFiles: (rootDir) => listPackableGitFiles(rootDir, GENERATED_OUTPUTS.map((name) => path.join(rootDir, name))),
34
+ listDirectoryFiles: listDirectoryFilesForInit,
35
+ readHead: readFileHead,
32
36
  readTextFile: readSourceTextFile,
33
37
  writeTextFile: (p, content) => fs.writeFileSync(p, content, "utf8"),
34
38
  appendTextFile: (p, content) => fs.appendFileSync(p, content, "utf8"),
@@ -1,11 +1,13 @@
1
1
  /**
2
- * pack / build / init が共有するファイル I/O と、入力(.sln / .vbproj / generic 構成)とルートの決め方。
2
+ * pack / build / init が共有するファイル I/O と、入力(.sln / .vbproj / .csproj / generic 構成)とルートの決め方。
3
3
  * src/pack/ の解析コアは deps 注入で I/O を持たないため、実際のファイルシステムをここでつなぐ。
4
4
  */
5
5
  import { spawnSync } from "node:child_process";
6
6
  import * as fs from "node:fs";
7
7
  import * as path from "node:path";
8
+ import { LEGACY_STATE_DIRECTORY, STATE_DIRECTORY } from "../brand.js";
8
9
  import { decodeSourceBuffer } from "../pack/services/repomixExporter.js";
10
+ import { collectGitFiles } from "../pack/services/extraRootsCollector.js";
9
11
  import { GitignoreEvaluator } from "../pack/services/gitignoreService.js";
10
12
  import { configFileNameIn, loadSlnmixConfig, readConfigFile, describeConfigConflict } from "../pack/slnmixConfig.js";
11
13
  import { describeRootReason, resolveRoot } from "../pack/rootResolver.js";
@@ -89,6 +91,111 @@ export function listGitFiles(rootDir) {
89
91
  const files = [...new Set(result.stdout.toString("utf8").split("\0").filter((p) => p !== ""))];
90
92
  return { ok: true, files };
91
93
  }
94
+ /**
95
+ * git の一覧から、パック自身の出力(ownOutputs。絶対パス)と、適用の履歴・PC ごとの設定(.tazuna/・
96
+ * 旧版の .petari/)を除く(.gitignore に書いていなくても。履歴は書き換え前後のファイルの写しと
97
+ * changes.md なので、入れると同じコードが重複する)
98
+ */
99
+ export function withoutOwnFiles(rootDir, files, ownOutputs) {
100
+ const own = new Set(ownOutputs.map((p) => path.relative(rootDir, p).split(path.sep).join("/").toLowerCase()));
101
+ const stateDirectories = [STATE_DIRECTORY, LEGACY_STATE_DIRECTORY].map((d) => `${d.toLowerCase()}/`);
102
+ return files.filter((file) => {
103
+ const lower = file.toLowerCase();
104
+ return !own.has(lower) && !stateDirectories.some((d) => lower.startsWith(d));
105
+ });
106
+ }
107
+ /**
108
+ * init が include を決めるための、git が管理しているファイル(パックと同じ既定の除外を済ませたもの。
109
+ * 既定の出力名・.gitignore / .repomixignore・バイナリの拡張子・ロックファイル・大きいもの)。
110
+ * git のリポジトリでない・一覧できなければ undefined
111
+ */
112
+ export function listPackableGitFiles(rootDir, ownOutputs) {
113
+ const listed = listGitFiles(rootDir);
114
+ if (!listed.ok) {
115
+ return undefined;
116
+ }
117
+ const gitignore = createGitignoreEvaluator(rootDir);
118
+ const collected = collectGitFiles(rootDir, withoutOwnFiles(rootDir, listed.files, ownOutputs), {
119
+ fileSize: fileSizeOf,
120
+ ignoreReasonFor: (absolutePath) => gitignore.ignoreReasonFor(absolutePath),
121
+ });
122
+ return collected.files.map((file) => ({
123
+ relativePath: file.relativePath,
124
+ size: fileSizeOf(file.absolutePath) ?? 0,
125
+ }));
126
+ }
127
+ /** init の走査で中に入らないディレクトリ(パックの既定の除外にあるもの) */
128
+ const ALWAYS_SKIPPED_DIRECTORIES = new Set(["node_modules", "dist", "build", "__pycache__"]);
129
+ /** 中に入らず、パックでも外すよう exclude に書くディレクトリ(ビルドの出力) */
130
+ const BUILD_OUTPUT_DIRECTORIES = new Set(["bin", "obj", "target"]);
131
+ /**
132
+ * git の外での init 用: ディレクトリの中のファイル(再帰)。ドットで始まるディレクトリ・Python の仮想環境
133
+ * (pyvenv.cfg のあるもの)・ビルドの出力(bin / obj / target)・node_modules などには入らない。
134
+ * シンボリックリンクは辿らない。読めなければ undefined
135
+ */
136
+ export function listDirectoryFilesForInit(absoluteDir) {
137
+ let entries;
138
+ try {
139
+ entries = fs.readdirSync(absoluteDir, { withFileTypes: true });
140
+ }
141
+ catch {
142
+ return undefined;
143
+ }
144
+ const result = { files: [], skippedDirs: [] };
145
+ const walk = (dir, relative, dirEntries) => {
146
+ for (const entry of dirEntries) {
147
+ const full = path.join(dir, entry.name);
148
+ const rel = relative === "" ? entry.name : `${relative}/${entry.name}`;
149
+ if (entry.isDirectory()) {
150
+ const lower = entry.name.toLowerCase();
151
+ if (ALWAYS_SKIPPED_DIRECTORIES.has(lower)) {
152
+ continue;
153
+ }
154
+ if (fs.existsSync(path.join(full, "pyvenv.cfg"))) {
155
+ result.skippedDirs.push({ relativePath: rel, reason: "Python の仮想環境" });
156
+ continue;
157
+ }
158
+ if (entry.name.startsWith(".")) {
159
+ result.skippedDirs.push({ relativePath: rel, reason: "ドットで始まるディレクトリ(ツールの設定・キャッシュなど)" });
160
+ continue;
161
+ }
162
+ if (BUILD_OUTPUT_DIRECTORIES.has(lower)) {
163
+ result.skippedDirs.push({ relativePath: rel, reason: "ビルドの出力" });
164
+ continue;
165
+ }
166
+ try {
167
+ walk(full, rel, fs.readdirSync(full, { withFileTypes: true }));
168
+ }
169
+ catch {
170
+ // 読めないディレクトリは飛ばす
171
+ }
172
+ }
173
+ else if (entry.isFile()) {
174
+ result.files.push({ relativePath: rel, size: fileSizeOf(full) ?? 0 });
175
+ }
176
+ }
177
+ };
178
+ walk(absoluteDir, "", entries);
179
+ return result;
180
+ }
181
+ /** ファイルの先頭(4KB)を文字コード自動判定で読む。読めなければ undefined */
182
+ export function readFileHead(absolutePath) {
183
+ let fd;
184
+ try {
185
+ fd = fs.openSync(absolutePath, "r");
186
+ const buffer = Buffer.alloc(4096);
187
+ const length = fs.readSync(fd, buffer, 0, buffer.length, 0);
188
+ return decodeSourceBuffer(buffer.subarray(0, length));
189
+ }
190
+ catch {
191
+ return undefined;
192
+ }
193
+ finally {
194
+ if (fd !== undefined) {
195
+ fs.closeSync(fd);
196
+ }
197
+ }
198
+ }
92
199
  export function listDirectoryNames(absolutePath) {
93
200
  try {
94
201
  return fs
@@ -155,7 +262,7 @@ export function printDiagnostics(label, diagnostics) {
155
262
  }
156
263
  }
157
264
  /**
158
- * 入力(.sln / .vbproj / ディレクトリ / 省略)とルートを決める(パックとビルドで同じ)。
265
+ * 入力(.sln / .vbproj / .csproj / ディレクトリ / 省略)とルートを決める(パックとビルドで同じ)。
159
266
  * solution: --root > 上位の設定ファイルの場所 > 上位の .git の場所 > 入力と同じ場所(rootResolver.ts)
160
267
  * generic: 設定ファイルの場所に固定(--root は使えない。基準が設定と食い違うため)
161
268
  */
@@ -166,6 +273,20 @@ function withConfigCheck(result) {
166
273
  }
167
274
  return result;
168
275
  }
276
+ /**
277
+ * 入力(省略時は自動検出)の .sln / .vbproj / .csproj を、何も出力せずに求める(--print-procedure で
278
+ * プロジェクトの言語を知るため)。見つからない・generic 構成なら undefined
279
+ */
280
+ export function findTargetQuietly(inputArg) {
281
+ const resolution = resolveTarget(inputArg, process.cwd(), {
282
+ isDirectory: isDirectoryPath,
283
+ isFile: isFilePath,
284
+ listFileNames: FS_DEPS.listFileNames,
285
+ readConfigTarget: (directory) => loadSlnmixConfig(directory, { readTextFile: readSourceTextFile }).config.target,
286
+ isGenericConfig: (directory) => loadSlnmixConfig(directory, { readTextFile: readSourceTextFile }).config.kind === "generic",
287
+ });
288
+ return resolution.kind === "file" ? resolution.path : undefined;
289
+ }
169
290
  export function resolveTargetAndRoot(inputArg, rootArg, options) {
170
291
  const resolution = resolveTarget(inputArg, process.cwd(), {
171
292
  isDirectory: isDirectoryPath,
@@ -173,7 +294,7 @@ export function resolveTargetAndRoot(inputArg, rootArg, options) {
173
294
  listFileNames: FS_DEPS.listFileNames,
174
295
  // 引数なし(またはディレクトリ指定)のとき、その場所の設定ファイルの target を使う
175
296
  readConfigTarget: (directory) => loadSlnmixConfig(directory, { readTextFile: readSourceTextFile }).config.target,
176
- // 同じ場所の設定が kind: "generic" なら .sln / .vbproj を探さない
297
+ // 同じ場所の設定が kind: "generic" なら .sln / .vbproj / .csproj を探さない
177
298
  isGenericConfig: (directory) => loadSlnmixConfig(directory, { readTextFile: readSourceTextFile }).config.kind === "generic",
178
299
  });
179
300
  if (resolution.kind === "error") {
@@ -195,7 +316,7 @@ export function resolveTargetAndRoot(inputArg, rootArg, options) {
195
316
  usageHint: false,
196
317
  };
197
318
  }
198
- err(`対象: generic 構成(${configName} の kind。.sln / .vbproj は使いません)`);
319
+ err(`対象: generic 構成(${configName} の kind。.sln / .vbproj / .csproj は使いません)`);
199
320
  err(`ルート: ${resolution.rootDir}`);
200
321
  return withConfigCheck({ kind: "ok", targetPath: undefined, rootDir: resolution.rootDir });
201
322
  }
@@ -2,13 +2,13 @@
2
2
  * tazuna pack — コードベースを AI チャットに渡す 1 ファイル(repomix 互換のパック)と、
3
3
  * チャット本文に貼る指示テキスト(.prompt.md)を作る(旧 slnmix)。
4
4
  *
5
- * .sln / .vbproj の論理構成(Link・DependentUpon 解決済み)か、設定ファイルの extraRoots に宣言した
5
+ * .sln / .vbproj / .csproj の論理構成(Link・DependentUpon 解決済み)か、設定ファイルの extraRoots に宣言した
6
6
  * ディレクトリ(kind: "generic")に基づく。解析・出力は src/pack/ のコアが担い、ここは引数処理とファイル I/O。
7
7
  */
8
8
  import * as fs from "node:fs";
9
9
  import * as path from "node:path";
10
10
  import { parseArgs } from "node:util";
11
- import { INIT_COMMAND, LEGACY_STATE_DIRECTORY, PACK_COMMAND, STATE_DIRECTORY, TOOL_NAME } from "../brand.js";
11
+ import { INIT_COMMAND, PACK_COMMAND, TOOL_NAME } from "../brand.js";
12
12
  import { writeClipboardSync } from "../infra/clipboard.js";
13
13
  import { err } from "../infra/term.js";
14
14
  import { maskCredentials } from "../core/mask.js";
@@ -17,27 +17,28 @@ import { describeAutoTests, detectAutoTests } from "../pack/autoTests.js";
17
17
  import { describeDbSchema, resolveDbSchema } from "../pack/dbChecks.js";
18
18
  import { buildDesignerFileMatcher } from "../pack/designerFileFilter.js";
19
19
  import { decideMode, describeDocs, resolveDocs } from "../pack/docs.js";
20
- import { planHandoff } from "../pack/handoff.js";
20
+ import { PASTE_LIMIT_CHARS, planHandoff } from "../pack/handoff.js";
21
21
  import { initConfig } from "../pack/initConfig.js";
22
- import { findRepositoryRoot } from "../pack/initProject.js";
22
+ import { describeCreatedGenericConfig, findRepositoryRoot, GENERATED_OUTPUTS } from "../pack/initProject.js";
23
23
  import { initDocs } from "../pack/initDocs.js";
24
24
  import { describeInstruction, resolveInstructionFile } from "../pack/instructionFile.js";
25
25
  import { assembleOutput, buildPromptText, resolvePlan, resolveProcedure, resolveTask, } from "../pack/procedureFile.js";
26
26
  import { DOC_TEMPLATES_DIR } from "../pack/assets/docTemplates.js";
27
- import { buildRepomixOutput } from "../pack/services/repomixExporter.js";
27
+ import { buildRepomixOutput, formatLabelCounts } from "../pack/services/repomixExporter.js";
28
28
  import { CONFIG_FILE_NAME, configFileNameIn, LEGACY_CONFIG_FILE_NAME, loadSlnmixConfig } from "../pack/slnmixConfig.js";
29
+ import { projectLanguageOf } from "../pack/projectLanguage.js";
29
30
  import { parseSln } from "../pack/slnParser.js";
30
31
  import { parseVbproj } from "../pack/vbprojParser.js";
31
- import { createGitignoreEvaluator, fileSizeOf, FS_DEPS, isDirectoryPath, isFilePath, listGitFiles, printDiagnostics, readSourceTextFile, resolveTargetAndRoot, } from "./pack-io.js";
32
+ import { createGitignoreEvaluator, fileSizeOf, findTargetQuietly, FS_DEPS, isDirectoryPath, isFilePath, listDirectoryFilesForInit, listDirectoryNames, listGitFiles, listPackableGitFiles, printDiagnostics, readFileHead, readSourceTextFile, resolveTargetAndRoot, withoutOwnFiles, } from "./pack-io.js";
32
33
  export const PACK_USAGE = `使い方:
33
- ${PACK_COMMAND} [<solution.sln | project.vbproj | ディレクトリ>] [オプション]
34
+ ${PACK_COMMAND} [<solution.sln | project.vbproj | project.csproj | ディレクトリ>] [オプション]
34
35
 
35
36
  入力を省略するとカレントディレクトリ(ディレクトリ指定ならその直下)の
36
- *.sln を自動検出します(なければ *.vbproj。複数ある場合は候補を表示)。
37
+ *.sln を自動検出します(なければ *.vbproj / *.csproj。複数ある場合は候補を表示)。
37
38
  その場所の設定ファイル(${CONFIG_FILE_NAME}。旧名の ${LEGACY_CONFIG_FILE_NAME} も読みます)に
38
39
  "target": "dotnet/App.sln" があればそれを使います。同じ設定が "kind": "generic" なら
39
- .sln / .vbproj を探さず、git が管理しているファイル(extraRoots を書けば、宣言した
40
- ディレクトリだけ)でパックします(VB.NET 以外のプロジェクト。${INIT_COMMAND} で作成)。
40
+ .sln / .vbproj / .csproj を探さず、git が管理しているファイル(extraRoots を書けば、宣言した
41
+ ディレクトリだけ)でパックします(.sln の無いプロジェクト。${INIT_COMMAND} で作成)。
41
42
 
42
43
  ルート(<file path> の基準。設定ファイル・protocol.md・docs/・出力先もここ)は
43
44
  --root > 入力のディレクトリから上に向かって最初に見つかる設定ファイルの場所
@@ -48,12 +49,12 @@ export const PACK_USAGE = `使い方:
48
49
  -o, --output <file> 出力先(既定: ルートの repomix-output.xml)
49
50
  --root <dir> ルートを明示する(入力はその配下にあること)
50
51
  --stdout ファイルではなく標準出力へ書く(BOM なし)
51
- --include-designer Designer 関連ファイル(*.Designer.vb 等)を原文のまま含める
52
+ --include-designer Designer 関連ファイル(*.Designer.vb / *.Designer.cs 等)を原文のまま含める
52
53
  --include-designer-file <名前|パターン>
53
54
  指定した Designer 関連ファイルだけ原文のまま含める
54
55
  (複数指定可。* をワイルドカードに使える。ファイル名
55
56
  または論理パスに全体一致)
56
- --no-ui-summary Designer.vb からの UI サマリー(<ui_summary>)生成を無効化
57
+ --no-ui-summary Designer.vb / Designer.cs からの UI サマリー(<ui_summary>)生成を無効化
57
58
  --no-mask 認証情報の自動マスク([MASKED] 置換)を無効化
58
59
  --no-strict-mask 高エントロピー文字列(ランダム英数字列)の機械的マスクを無効化
59
60
  --no-gitignore .gitignore / .repomixignore による除外を無効化
@@ -73,8 +74,9 @@ export const PACK_USAGE = `使い方:
73
74
  --design <名前|file>
74
75
  design モードで対象の設計書を指定
75
76
  --init-docs docs/ 連携だけを設定する(${INIT_COMMAND} に含まれる)
76
- --init-config VB.NET 以外のプロジェクト向けの ${CONFIG_FILE_NAME}
77
- (kind: "generic")だけを作る(${INIT_COMMAND} に含まれる)
77
+ --init-config .sln の無いプロジェクト向けの ${CONFIG_FILE_NAME}
78
+ (kind: "generic"。拡張子を見て include / exclude を書く)
79
+ だけを作る(${INIT_COMMAND} に含まれる)
78
80
  --plan <file> implement モードで承認済みの方針を <plan> として同梱する
79
81
  --procedure-file <path>
80
82
  作業手順文を明示指定(既定: ルートの procedure.md。なければ内蔵既定文)
@@ -94,18 +96,32 @@ M365 Copilot Chat への渡し方:
94
96
  (repomix-output.xml)を添付し、本文に貼って送信する。添付ファイル内の指示は
95
97
  Copilot が「埋め込み指示」として無視するため、手順文・規約文は本文側で渡す
96
98
  `;
97
- /**
98
- * M365 Copilot Chat の入力欄に貼れる上限の目安(文字)。超えると送信ボタンが
99
- * 非活性になる(2026-09-12 実測: 約 120K 文字。設計書 §15.1)
100
- */
101
- const PASTE_LIMIT_CHARS = 120_000;
102
99
  /** パックの出力パスから本文用テキストの既定パスを作る(拡張子を .prompt.md に) */
103
100
  function defaultPromptPath(outputPath) {
104
101
  const ext = path.extname(outputPath);
105
102
  const base = ext === "" ? outputPath : outputPath.slice(0, -ext.length);
106
103
  return `${base}.prompt.md`;
107
104
  }
108
- /** 入力(.sln / .vbproj)から RepomixSource[] を組み立てる */
105
+ /**
106
+ * --print-procedure 用: 入力(省略時は自動検出)のプロジェクトの言語。診断は出さない
107
+ * (手順文を標準出力に書くだけのため)。入力が見つからなければ undefined(Visual Basic の文面)
108
+ */
109
+ function languagesForPrint(input) {
110
+ const targetPath = findTargetQuietly(input);
111
+ if (targetPath === undefined) {
112
+ return undefined;
113
+ }
114
+ if (!/\.sln$/i.test(targetPath)) {
115
+ const language = projectLanguageOf(targetPath);
116
+ return language === undefined ? undefined : [language];
117
+ }
118
+ const content = readSourceTextFile(targetPath);
119
+ if (content === undefined) {
120
+ return undefined;
121
+ }
122
+ return parseSln(content, targetPath, FS_DEPS).projects.map((project) => project.language);
123
+ }
124
+ /** 入力(.sln / .vbproj / .csproj)から RepomixSource[] を組み立てる */
109
125
  function collectSources(targetPath) {
110
126
  const content = readSourceTextFile(targetPath);
111
127
  if (content === undefined) {
@@ -132,7 +148,7 @@ function collectSources(targetPath) {
132
148
  return sources;
133
149
  }
134
150
  const parseResult = parseVbproj(content, targetPath, FS_DEPS);
135
- const label = path.basename(targetPath).replace(/\.vbproj$/i, "");
151
+ const label = path.basename(targetPath).replace(/\.(vbproj|csproj)$/i, "");
136
152
  printDiagnostics(label, parseResult.diagnostics);
137
153
  return [{ label, parseResult }];
138
154
  }
@@ -188,6 +204,8 @@ export function packCommand(argv) {
188
204
  tests: "placeholder",
189
205
  db: "placeholder",
190
206
  layout: printConfig.config.kind,
207
+ // C# のプロジェクトがあれば C# の語句にする(入力が見つからなければ Visual Basic)
208
+ languages: printConfig.config.kind === "generic" ? undefined : languagesForPrint(positionals[0]),
191
209
  }));
192
210
  return 0;
193
211
  }
@@ -199,7 +217,7 @@ export function packCommand(argv) {
199
217
  err("--plan は --mode implement でのみ使えます。");
200
218
  return 1;
201
219
  }
202
- // VB.NET 以外のプロジェクト向けの設定ファイルを作る(入力の解決より前。.sln は無い前提)
220
+ // .sln の無いプロジェクト向けの設定ファイルを作る(入力の解決より前。.sln は無い前提)
203
221
  if (values["init-config"]) {
204
222
  const initRoot = path.resolve(process.cwd(), values.root ?? positionals[0] ?? ".");
205
223
  const result = initConfig(initRoot, {
@@ -207,6 +225,10 @@ export function packCommand(argv) {
207
225
  isFile: isFilePath,
208
226
  listFileNames: FS_DEPS.listFileNames,
209
227
  writeTextFile: (p, content) => fs.writeFileSync(p, content, "utf8"),
228
+ listPackableGitFiles: (rootDir) => listPackableGitFiles(rootDir, GENERATED_OUTPUTS.map((name) => path.join(rootDir, name))),
229
+ listDirectoryFiles: listDirectoryFilesForInit,
230
+ listDirectoryNames,
231
+ readHead: readFileHead,
210
232
  }, { gitRepository: findRepositoryRoot(initRoot, (p) => fs.existsSync(p)) !== undefined });
211
233
  if (result.kind === "error") {
212
234
  err(result.message);
@@ -217,14 +239,12 @@ export function packCommand(argv) {
217
239
  return 0;
218
240
  }
219
241
  err(`作成: ${result.path}`);
220
- if (result.roots.length === 0) {
221
- err(`以後は同じ場所で npx ${PACK_COMMAND} を実行すると、git が管理しているファイルでパックと本文用テキストを作ります。対象を絞るときは .repomixignore に除外を書くか、extraRoots にディレクトリを書いてください。`);
222
- return 0;
223
- }
224
- for (const root of result.roots) {
225
- err(` extraRoots: ${root.path}/(kind: "${root.kind}")`);
242
+ for (const line of describeCreatedGenericConfig(result, path.basename(result.path))) {
243
+ err(` ${line}`);
226
244
  }
227
- err(`以後は同じ場所で npx ${PACK_COMMAND} を実行すると、extraRoots のディレクトリだけでパックと本文用テキストを作ります。対象を増やすときは extraRoots に path を追記してください。`);
245
+ err(result.roots.length === 0
246
+ ? `以後は同じ場所で npx ${PACK_COMMAND} を実行すると、git が管理しているファイル${result.plan === undefined ? "" : "のうち include に一致するもの"}でパックと本文用テキストを作ります。`
247
+ : `以後は同じ場所で npx ${PACK_COMMAND} を実行すると、extraRoots のディレクトリだけでパックと本文用テキストを作ります。対象を増やすときは extraRoots に path を追記してください。`);
228
248
  return 0;
229
249
  }
230
250
  if (positionals.length > 1) {
@@ -304,25 +324,24 @@ export function packCommand(argv) {
304
324
  // パック自身の出力(前回の分)は入れない(.gitignore に書いていなくても。本家 repomix と同じ)
305
325
  const defaultOutput = path.join(rootDir, "repomix-output.xml");
306
326
  const outputFile = path.resolve(values.output ?? defaultOutput);
307
- const ownOutputs = new Set([
327
+ gitFiles = withoutOwnFiles(rootDir, listed.files, [
308
328
  defaultOutput,
309
329
  defaultPromptPath(defaultOutput),
310
330
  outputFile,
311
331
  values["prompt-output"] === undefined ? defaultPromptPath(outputFile) : path.resolve(values["prompt-output"]),
312
- ].map((p) => path.relative(rootDir, p).split(path.sep).join("/").toLowerCase()));
313
- // 適用の履歴と PC ごとの設定(.tazuna/・旧版の .petari/)も入れない(.gitignore に書いていなくても。
314
- // 履歴は書き換え前後のファイルの写しと changes.md なので、入れると同じコードが重複する)
315
- const stateDirectories = [STATE_DIRECTORY, LEGACY_STATE_DIRECTORY].map((d) => `${d.toLowerCase()}/`);
316
- gitFiles = listed.files.filter((file) => {
317
- const lower = file.toLowerCase();
318
- return !ownOutputs.has(lower) && !stateDirectories.some((d) => lower.startsWith(d));
319
- });
332
+ ]);
320
333
  }
321
334
  if (layout === "solution" && config.kind === "generic") {
322
- err(`[warning] ${configName} は kind: "generic" ですが、入力に .sln / .vbproj が指定されたため従来どおり論理構成で出力します`);
335
+ err(`[warning] ${configName} は kind: "generic" ですが、入力に .sln / .vbproj / .csproj が指定されたため従来どおり論理構成で出力します`);
323
336
  }
324
337
  if (config.sources.length > 0) {
325
338
  const parts = [gitFiles !== undefined ? "git が管理しているファイル" : `extraRoots ${config.extraRoots.length} 件`];
339
+ if (gitFiles !== undefined && config.include !== undefined) {
340
+ parts.push(`include ${config.include.length} 件`);
341
+ }
342
+ if (gitFiles !== undefined && config.exclude.length > 0) {
343
+ parts.push(`exclude ${config.exclude.length} 件`);
344
+ }
326
345
  if (config.contractSchema !== undefined) {
327
346
  parts.push(`契約スキーマ ${config.contractSchema}`);
328
347
  }
@@ -367,6 +386,8 @@ export function packCommand(argv) {
367
386
  extraRoots: config.extraRoots,
368
387
  gitFiles,
369
388
  gitFilesShownElsewhere: (relativePath) => shownElsewhere.get(relativePath.toLowerCase()),
389
+ gitInclude: config.include,
390
+ gitExclude: config.exclude,
370
391
  configFileName: configName,
371
392
  contractSchema: config.contractSchema,
372
393
  contractFile: config.contractFile,
@@ -375,6 +396,16 @@ export function packCommand(argv) {
375
396
  layout,
376
397
  });
377
398
  printDiagnostics("出力", output.diagnostics);
399
+ // include に一致しないもの(新しく足した言語のファイルなど)に気づけるよう、件数と拡張子を出す
400
+ const filtered = output.gitFilesFiltered;
401
+ if (filtered !== undefined && (filtered.notIncluded > 0 || filtered.excluded > 0)) {
402
+ err(`設定で入れていないファイル: ${[
403
+ ...(filtered.notIncluded > 0
404
+ ? [`include に一致しない ${filtered.notIncluded} 件(${formatLabelCounts(filtered.notIncludedByLabel)})`]
405
+ : []),
406
+ ...(filtered.excluded > 0 ? [`exclude に一致 ${filtered.excluded} 件`] : []),
407
+ ].join("、")}`);
408
+ }
378
409
  if (layout === "generic" && output.fileCount === 0) {
379
410
  err(gitFiles !== undefined
380
411
  ? `出力対象のファイルがありません(git が管理しているファイルが無いか、すべて除外されました。除外の理由は --stdout の <skipped_files> に出ます)。`
@@ -457,6 +488,7 @@ export function packCommand(argv) {
457
488
  tests: autoTests.present,
458
489
  db: dbSchema !== undefined,
459
490
  layout,
491
+ languages: sources.map((source) => source.parseResult.language),
460
492
  }, rootDir, process.cwd(), textDeps);
461
493
  if (procedure.kind === "error") {
462
494
  err(procedure.message);