tazuna 0.17.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 +2 -1
- package/dist/commands/init.js +6 -2
- package/dist/commands/pack-io.js +107 -0
- package/dist/commands/pack.js +36 -27
- package/dist/pack/handoff.js +10 -0
- package/dist/pack/includePlanner.js +610 -0
- package/dist/pack/initConfig.js +128 -9
- package/dist/pack/initProject.js +44 -15
- package/dist/pack/services/extraRootsCollector.js +46 -2
- package/dist/pack/services/repomixExporter.js +36 -4
- package/dist/pack/slnmixConfig.js +44 -1
- package/package.json +1 -1
package/dist/pack/initConfig.js
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tazuna pack --init-config: .sln の無いプロジェクト(TypeScript
|
|
2
|
+
* tazuna pack --init-config: .sln の無いプロジェクト(TypeScript・Python・Go など)で使う
|
|
3
3
|
* ための設定ファイル(tazuna.config.json、kind: "generic")を作る(旧 slnmix v0.17.0、設計書 §19)。
|
|
4
|
+
* tazuna init も .sln などが無いときはこれを使う。
|
|
4
5
|
*
|
|
5
6
|
* - 既に設定ファイルがあれば(旧名の slnmix.config.json でも)何もしない(冪等。中身は変えない)
|
|
6
7
|
* - その場所に .sln / .vbproj / .csproj があれば作らない(従来の solution 構成で動くため)
|
|
7
|
-
* - git のリポジトリの中なら extraRoots を書かない(git が管理しているファイルが対象。設計書 §25.7)
|
|
8
|
+
* - git のリポジトリの中なら extraRoots を書かない(git が管理しているファイルが対象。設計書 §25.7)。
|
|
9
|
+
* v0.18.0 から、実際にあるファイルの拡張子を見て include / exclude を書く(includePlanner.ts)。
|
|
10
|
+
* ファイルがまだ無ければ書かない(すべてが対象)
|
|
8
11
|
* - git の外では、ソースのディレクトリは「候補名のうち実在するもの」だけを採用する(src / app /
|
|
9
12
|
* lib / apps / packages → kind: "src"、tests / test / e2e / __tests__ →
|
|
10
|
-
* kind: "test")
|
|
13
|
+
* kind: "test")。候補が無ければ、直下のディレクトリのうち言語の分かるソースを含むものを使う
|
|
14
|
+
* (v0.18.0)。それぞれの include / exclude も中のファイルの拡張子から書く。1 つも無ければ推測で
|
|
15
|
+
* 書かずエラーにし、例を示す
|
|
11
16
|
*
|
|
12
17
|
* ファイルシステムは deps 注入(単体テスト可能)。
|
|
13
18
|
*/
|
|
14
19
|
import * as path from "node:path";
|
|
15
20
|
import { PACK_COMMAND } from "../brand.js";
|
|
21
|
+
import { planInclude } from "./includePlanner.js";
|
|
16
22
|
import { CONFIG_FILE_NAME, configFileNameIn, hasConfigFile } from "./slnmixConfig.js";
|
|
23
|
+
/**
|
|
24
|
+
* git の一覧から決める include に、ファイルが無くても入れるもの(init が続けて作る docs/ の Markdown・
|
|
25
|
+
* .gitignore・設定ファイル自身。設定ファイルは AI がパックの範囲を知る手がかりになる)
|
|
26
|
+
*/
|
|
27
|
+
export const ALWAYS_INCLUDE = ["**/*.md", "**/.gitignore", CONFIG_FILE_NAME];
|
|
28
|
+
/** git の外で候補のディレクトリが無いとき、直下のディレクトリのうち見ないもの(docs/ は <docs> に入る) */
|
|
29
|
+
const SKIPPED_TOP_DIRECTORIES = new Set(["node_modules", "dist", "build", "bin", "obj", "target", "docs", "__pycache__"]);
|
|
17
30
|
/** ソースの候補ディレクトリ(この順で並ぶ) */
|
|
18
31
|
export const SOURCE_DIR_CANDIDATES = ["src", "app", "lib", "apps", "packages"];
|
|
19
32
|
/** 自動テストの候補ディレクトリ */
|
|
@@ -27,8 +40,29 @@ export const EXAMPLE_CONFIG = `{
|
|
|
27
40
|
]
|
|
28
41
|
}`;
|
|
29
42
|
function renderConfig(roots) {
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
return `${JSON.stringify({
|
|
44
|
+
kind: "generic",
|
|
45
|
+
extraRoots: roots.map((root) => {
|
|
46
|
+
const exclude = [
|
|
47
|
+
...(root.plan?.exclude ?? []),
|
|
48
|
+
...(root.skippedDirs ?? []).map((dir) => `${dir.relativePath}/**`),
|
|
49
|
+
];
|
|
50
|
+
return {
|
|
51
|
+
path: root.path,
|
|
52
|
+
kind: root.kind,
|
|
53
|
+
...(root.plan !== undefined && root.plan.include.length > 0 ? { include: root.plan.include } : {}),
|
|
54
|
+
...(exclude.length > 0 ? { exclude } : {}),
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
}, null, 2)}\n`;
|
|
58
|
+
}
|
|
59
|
+
/** git が管理しているファイルを対象にし、拡張子から決めた include / exclude を書く generic 構成 */
|
|
60
|
+
export function renderGitGenericConfig(plan) {
|
|
61
|
+
return `${JSON.stringify({
|
|
62
|
+
kind: "generic",
|
|
63
|
+
include: plan.include,
|
|
64
|
+
...(plan.exclude.length > 0 ? { exclude: plan.exclude } : {}),
|
|
65
|
+
}, null, 2)}\n`;
|
|
32
66
|
}
|
|
33
67
|
/** git が管理しているファイルを対象にする generic 構成(extraRoots なし。設計書 §25.7) */
|
|
34
68
|
export const GIT_GENERIC_CONFIG = `{
|
|
@@ -57,8 +91,16 @@ export function initConfig(rootDir, deps, options = {}) {
|
|
|
57
91
|
};
|
|
58
92
|
}
|
|
59
93
|
if (options.gitRepository === true) {
|
|
60
|
-
deps.
|
|
61
|
-
|
|
94
|
+
const files = deps.listPackableGitFiles?.(rootDir);
|
|
95
|
+
if (files === undefined || files.length === 0) {
|
|
96
|
+
// まだファイルが無い(新しいリポジトリ)など: 拡張子から決められないので、すべてを対象にする
|
|
97
|
+
deps.writeTextFile(configPath, GIT_GENERIC_CONFIG);
|
|
98
|
+
return { kind: "created", path: configPath, content: GIT_GENERIC_CONFIG, roots: [] };
|
|
99
|
+
}
|
|
100
|
+
const plan = planInclude({ files, readHead: (relativePath) => deps.readHead?.(path.join(rootDir, ...relativePath.split("/"))) }, { alwaysInclude: ALWAYS_INCLUDE });
|
|
101
|
+
const content = renderGitGenericConfig(plan);
|
|
102
|
+
deps.writeTextFile(configPath, content);
|
|
103
|
+
return { kind: "created", path: configPath, content, roots: [], plan };
|
|
62
104
|
}
|
|
63
105
|
const roots = [];
|
|
64
106
|
for (const name of SOURCE_DIR_CANDIDATES) {
|
|
@@ -66,16 +108,38 @@ export function initConfig(rootDir, deps, options = {}) {
|
|
|
66
108
|
roots.push({ path: name, kind: "src" });
|
|
67
109
|
}
|
|
68
110
|
}
|
|
111
|
+
if (roots.length === 0 && deps.listDirectoryFiles !== undefined && deps.listDirectoryNames !== undefined) {
|
|
112
|
+
// 候補名のディレクトリが無ければ、直下のディレクトリのうち言語の分かるソースを含むもの(例: Python の
|
|
113
|
+
// パッケージのディレクトリ)。見つけたものは設定に書くので利用者に見える
|
|
114
|
+
const names = (deps.listDirectoryNames(rootDir) ?? [])
|
|
115
|
+
.filter((name) => !name.startsWith(".") && !SKIPPED_TOP_DIRECTORIES.has(name.toLowerCase()))
|
|
116
|
+
.filter((name) => !TEST_DIR_CANDIDATES.includes(name))
|
|
117
|
+
.sort((a, b) => a.localeCompare(b));
|
|
118
|
+
for (const name of names) {
|
|
119
|
+
if (deps.isFile(path.join(rootDir, name, "pyvenv.cfg"))) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const planned = planRoot(rootDir, name, deps);
|
|
123
|
+
if (planned?.plan !== undefined && planned.plan.languages.length > 0) {
|
|
124
|
+
roots.push({ path: name, kind: "src", ...planned });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
for (const root of roots) {
|
|
130
|
+
Object.assign(root, planRoot(rootDir, root.path, deps));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
69
133
|
for (const name of TEST_DIR_CANDIDATES) {
|
|
70
134
|
if (deps.isDirectory(path.join(rootDir, name))) {
|
|
71
|
-
roots.push({ path: name, kind: "test" });
|
|
135
|
+
roots.push({ path: name, kind: "test", ...planRoot(rootDir, name, deps) });
|
|
72
136
|
}
|
|
73
137
|
}
|
|
74
138
|
if (!roots.some((root) => root.kind === "src")) {
|
|
75
139
|
return {
|
|
76
140
|
kind: "error",
|
|
77
141
|
message: [
|
|
78
|
-
`${rootDir} にソースのディレクトリ(${SOURCE_DIR_CANDIDATES.join(" / ")})が見つかりません。推測では作らないので、${CONFIG_FILE_NAME} を手で作ってください。例:`,
|
|
142
|
+
`${rootDir} にソースのディレクトリ(${SOURCE_DIR_CANDIDATES.join(" / ")}、または言語の分かるソースを含むディレクトリ)が見つかりません。推測では作らないので、${CONFIG_FILE_NAME} を手で作ってください。例:`,
|
|
79
143
|
EXAMPLE_CONFIG,
|
|
80
144
|
].join("\n"),
|
|
81
145
|
};
|
|
@@ -84,3 +148,58 @@ export function initConfig(rootDir, deps, options = {}) {
|
|
|
84
148
|
deps.writeTextFile(configPath, content);
|
|
85
149
|
return { kind: "created", path: configPath, content, roots };
|
|
86
150
|
}
|
|
151
|
+
/** extraRoots の 1 つのディレクトリの include / exclude を中のファイルから決める(走査できなければ undefined) */
|
|
152
|
+
function planRoot(rootDir, name, deps) {
|
|
153
|
+
const listed = deps.listDirectoryFiles?.(path.join(rootDir, name));
|
|
154
|
+
if (listed === undefined) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
const plan = planInclude({
|
|
158
|
+
files: listed.files,
|
|
159
|
+
readHead: (relativePath) => deps.readHead?.(path.join(rootDir, name, ...relativePath.split("/"))),
|
|
160
|
+
});
|
|
161
|
+
return {
|
|
162
|
+
plan: plan.include.length > 0 ? plan : undefined,
|
|
163
|
+
skippedDirs: listed.skippedDirs.length > 0 ? listed.skippedDirs : undefined,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function formatKiloChars(bytes) {
|
|
167
|
+
return bytes < 1000 ? `${bytes}` : `${Math.round(bytes / 1000)}K`;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 拡張子から決めた include / exclude の説明(init と --init-config の表示用。1 要素 1 行、字下げなし)。
|
|
171
|
+
* @param scope 何から決めたか(例: "git が管理しているファイル"・"src/")
|
|
172
|
+
*/
|
|
173
|
+
export function describeIncludePlan(plan, scope) {
|
|
174
|
+
const lines = [];
|
|
175
|
+
lines.push(plan.languages.length === 0
|
|
176
|
+
? `言語: (${scope}に言語の分かるソースがありません)`
|
|
177
|
+
: `言語: ${plan.languages.map((language) => `${language.name} ${language.count} 件`).join(" / ")}`);
|
|
178
|
+
lines.push(`include: ${plan.include.join(", ")}`);
|
|
179
|
+
if (plan.excluded.length > 0) {
|
|
180
|
+
lines.push(`exclude: ${plan.excluded
|
|
181
|
+
.map((entry) => `${entry.pattern}(${entry.reason}${entry.count > 0 ? ` ${entry.count} 件` : ""})`)
|
|
182
|
+
.join(" / ")}`);
|
|
183
|
+
}
|
|
184
|
+
if (plan.omitted.length > 0) {
|
|
185
|
+
const shown = plan.omitted.slice(0, 8);
|
|
186
|
+
const rest = plan.omitted.length - shown.length;
|
|
187
|
+
lines.push(`入れないもの: ${[
|
|
188
|
+
...shown.map((entry) => `${entry.label} ${entry.count} 件(${entry.reason}。例: ${entry.example})`),
|
|
189
|
+
...(rest > 0 ? [`ほか ${rest} 種類`] : []),
|
|
190
|
+
].join(" / ")}`);
|
|
191
|
+
}
|
|
192
|
+
return lines;
|
|
193
|
+
}
|
|
194
|
+
/** git の一覧から決めたときの、パックの大きさの目安(貼り付けの上限との比較) */
|
|
195
|
+
export function describePackSize(plan, pasteLimit, overhead) {
|
|
196
|
+
const estimate = plan.includedBytes + overhead;
|
|
197
|
+
const head = `ファイルの中身: ${plan.includedCount} 件・約 ${formatKiloChars(plan.includedBytes)} 文字`;
|
|
198
|
+
if (estimate <= pasteLimit) {
|
|
199
|
+
return [`${head}(手順文などを足しても、貼り付けの上限の目安 約 ${formatKiloChars(pasteLimit)} 文字に収まる見込み)`];
|
|
200
|
+
}
|
|
201
|
+
return [
|
|
202
|
+
`${head}。手順文などを足すと貼り付けの上限の目安(約 ${formatKiloChars(pasteLimit)} 文字)を超える見込みで、その場合はパックを添付で渡します(本文用テキストがクリップボードに入ります)`,
|
|
203
|
+
`大きいもの: ${plan.largest.map((file) => `${file.relativePath}(約 ${formatKiloChars(file.size)} 文字)`).join(" / ")}。要らなければ exclude に足してください`,
|
|
204
|
+
];
|
|
205
|
+
}
|
package/dist/pack/initProject.js
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import * as path from "node:path";
|
|
24
24
|
import { GitignoreRules } from "./services/gitignoreMatcher.js";
|
|
25
|
-
import { initConfig } from "./initConfig.js";
|
|
25
|
+
import { describeIncludePlan, describePackSize, initConfig, } from "./initConfig.js";
|
|
26
|
+
import { PACK_OVERHEAD_CHARS, PASTE_LIMIT_CHARS } from "./handoff.js";
|
|
26
27
|
import { initDocs } from "./initDocs.js";
|
|
27
28
|
import { BUILD_COMMAND, PACK_COMMAND, TOOL_NAME, stateDirectoryName } from "../brand.js";
|
|
28
29
|
import { CONFIG_TEMPLATE } from "../infra/config.js";
|
|
@@ -184,27 +185,55 @@ function setUpLayout(rootDir, deps) {
|
|
|
184
185
|
if (result.kind === "kept") {
|
|
185
186
|
return { kind: "ok", layout: "generic", lines: [`1. 構成: 既存の ${configName}(変更なし)`] };
|
|
186
187
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
`1. 構成: generic(.sln / .vbproj / .csproj が無いため、git が管理しているファイルを対象にする ${configName} を作りました)`,
|
|
193
|
-
` 対象を絞るときは .repomixignore に除外を書くか、${configName} の extraRoots にディレクトリを書いてください`,
|
|
194
|
-
` VB.NET / C# のプロジェクトで .sln が 2 段以上深い場合は見つけられません。kind の代わりに "target": "<パス>/<名前>.sln" を書いてください`,
|
|
195
|
-
],
|
|
196
|
-
};
|
|
197
|
-
}
|
|
188
|
+
const heading = result.roots.length > 0
|
|
189
|
+
? `1. 構成: generic(.sln / .vbproj / .csproj が無いため ${configName} を作りました)`
|
|
190
|
+
: result.plan === undefined
|
|
191
|
+
? `1. 構成: generic(.sln / .vbproj / .csproj が無いため、git が管理しているファイルを対象にする ${configName} を作りました)`
|
|
192
|
+
: `1. 構成: generic(.sln / .vbproj / .csproj が無いため、git が管理しているファイルの拡張子を見て ${configName} を作りました)`;
|
|
198
193
|
return {
|
|
199
194
|
kind: "ok",
|
|
200
195
|
layout: "generic",
|
|
201
196
|
lines: [
|
|
202
|
-
|
|
203
|
-
...result.
|
|
204
|
-
` VB.NET / C# のプロジェクトで .sln が 2 段以上深い場合は見つけられません。kind と extraRoots の代わりに "target": "<パス>/<名前>.sln" を書いてください`,
|
|
197
|
+
heading,
|
|
198
|
+
...describeCreatedGenericConfig(result, configName).map((line) => ` ${line}`),
|
|
199
|
+
` VB.NET / C# のプロジェクトで .sln が 2 段以上深い場合は見つけられません。kind${result.roots.length === 0 ? "" : " と extraRoots"}${result.plan === undefined ? "" : "・include・exclude"} の代わりに "target": "<パス>/<名前>.sln" を書いてください`,
|
|
205
200
|
],
|
|
206
201
|
};
|
|
207
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* initConfig が作った generic 構成の説明(init と pack --init-config の表示用。字下げなし)。
|
|
205
|
+
* 拡張子から決めた include / exclude・入れないもの・大きさの目安
|
|
206
|
+
*/
|
|
207
|
+
export function describeCreatedGenericConfig(result, configName) {
|
|
208
|
+
if (result.roots.length > 0) {
|
|
209
|
+
return [
|
|
210
|
+
...result.roots.flatMap((root) => [
|
|
211
|
+
`extraRoots: ${root.path}/(kind: "${root.kind}")`,
|
|
212
|
+
...describeRootPlan(root).map((line) => ` ${line}`),
|
|
213
|
+
]),
|
|
214
|
+
`git のリポジトリでないため、extraRoots のディレクトリだけが対象です(直下のファイルは入りません。git のリポジトリにすると、git が管理しているファイルを対象にできます)`,
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
if (result.plan === undefined) {
|
|
218
|
+
return [
|
|
219
|
+
`まだファイルが無いため、拡張子から include を決めていません(git が管理しているファイルがすべて対象。ファイルを足した後で ${configName} に include を書けます)`,
|
|
220
|
+
`対象を絞るときは ${configName} に include / exclude を書くか、.repomixignore に除外を書いてください`,
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
return [
|
|
224
|
+
...describeIncludePlan(result.plan, "git が管理しているファイル"),
|
|
225
|
+
...describePackSize(result.plan, PASTE_LIMIT_CHARS, PACK_OVERHEAD_CHARS),
|
|
226
|
+
`対象を変えるときは ${configName} の include / exclude を書き換えてください(include に一致しないものはパックに入りません)`,
|
|
227
|
+
];
|
|
228
|
+
}
|
|
229
|
+
/** git の外の extraRoots の 1 つについて、決めた include / exclude の説明 */
|
|
230
|
+
function describeRootPlan(root) {
|
|
231
|
+
const skipped = (root.skippedDirs ?? []).map((dir) => ({ pattern: `${dir.relativePath}/**`, reason: dir.reason, count: 0 }));
|
|
232
|
+
if (root.plan === undefined) {
|
|
233
|
+
return skipped.length === 0 ? [] : [`exclude: ${skipped.map((entry) => `${entry.pattern}(${entry.reason})`).join(" / ")}`];
|
|
234
|
+
}
|
|
235
|
+
return describeIncludePlan({ ...root.plan, excluded: [...root.plan.excluded, ...skipped] }, `${root.path}/ `);
|
|
236
|
+
}
|
|
208
237
|
function toRelative(rootDir, absolutePath) {
|
|
209
238
|
return path.relative(rootDir, absolutePath).split(path.sep).join("/");
|
|
210
239
|
}
|
|
@@ -127,10 +127,15 @@ export const GIT_FILES_KIND = "git";
|
|
|
127
127
|
* @param rootDir ルートの絶対パス(relativePaths の基準)
|
|
128
128
|
* @param relativePaths ルート相対のパス(`/` 区切り)
|
|
129
129
|
*/
|
|
130
|
-
export function collectGitFiles(rootDir, relativePaths, deps) {
|
|
130
|
+
export function collectGitFiles(rootDir, relativePaths, deps, filters = {}) {
|
|
131
131
|
const files = [];
|
|
132
132
|
const skipped = [];
|
|
133
133
|
let alwaysExcludedCount = 0;
|
|
134
|
+
const includeRegExps = filters.include?.map(globToRegExp);
|
|
135
|
+
const excludeRegExps = (filters.exclude ?? []).map(globToRegExp);
|
|
136
|
+
const notIncluded = new Map();
|
|
137
|
+
let notIncludedCount = 0;
|
|
138
|
+
let excludedCount = 0;
|
|
134
139
|
for (const raw of relativePaths) {
|
|
135
140
|
const relativePath = normalizeGlobPath(raw);
|
|
136
141
|
if (relativePath === "" || relativePath.startsWith("../") || relativePath.startsWith("/")) {
|
|
@@ -160,6 +165,19 @@ export function collectGitFiles(rootDir, relativePaths, deps) {
|
|
|
160
165
|
skipped.push({ relativePath, reason: `.gitignore により除外(${ignoreSource})` });
|
|
161
166
|
continue;
|
|
162
167
|
}
|
|
168
|
+
// 設定の include / exclude(tazuna init が拡張子から書く)。数が多くなり得るので 1 件ずつは
|
|
169
|
+
// <skipped_files> に載せず、件数と拡張子ごとの内訳を残す(バイナリ・ロックファイルなど、
|
|
170
|
+
// 設定によらず入らないものは上で理由を残す)
|
|
171
|
+
if (includeRegExps !== undefined && !includeRegExps.some((re) => re.test(relativePath))) {
|
|
172
|
+
notIncludedCount += 1;
|
|
173
|
+
const label = labelOf(relativePath);
|
|
174
|
+
notIncluded.set(label, (notIncluded.get(label) ?? 0) + 1);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (excludeRegExps.some((re) => re.test(relativePath))) {
|
|
178
|
+
excludedCount += 1;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
163
181
|
const size = deps.fileSize(absolutePath);
|
|
164
182
|
if (size === undefined) {
|
|
165
183
|
skipped.push({ relativePath, reason: "通常のファイルではない(削除済み・サブモジュールなど)" });
|
|
@@ -175,14 +193,40 @@ export function collectGitFiles(rootDir, relativePaths, deps) {
|
|
|
175
193
|
files.push({ kind: GIT_FILES_KIND, rootPath: "", relativePath, absolutePath });
|
|
176
194
|
}
|
|
177
195
|
files.sort((a, b) => a.relativePath.toLowerCase().localeCompare(b.relativePath.toLowerCase()));
|
|
196
|
+
const filtered = includeRegExps === undefined && excludeRegExps.length === 0
|
|
197
|
+
? undefined
|
|
198
|
+
: {
|
|
199
|
+
notIncluded: notIncludedCount,
|
|
200
|
+
notIncludedByLabel: [...notIncluded.entries()]
|
|
201
|
+
.map(([label, count]) => ({ label, count }))
|
|
202
|
+
.sort((a, b) => b.count - a.count || a.label.localeCompare(b.label)),
|
|
203
|
+
excluded: excludedCount,
|
|
204
|
+
};
|
|
205
|
+
const filterParts = filtered === undefined
|
|
206
|
+
? []
|
|
207
|
+
: [
|
|
208
|
+
...(includeRegExps === undefined ? [] : [`include に一致しない ${filtered.notIncluded} 件`]),
|
|
209
|
+
...(excludeRegExps.length === 0 ? [] : [`exclude に一致 ${filtered.excluded} 件`]),
|
|
210
|
+
];
|
|
178
211
|
return {
|
|
179
212
|
files,
|
|
180
213
|
skipped,
|
|
181
214
|
diagnostics: [
|
|
182
215
|
{
|
|
183
216
|
severity: "info",
|
|
184
|
-
message: `git が管理しているファイル: ${files.length} 件(
|
|
217
|
+
message: `git が管理しているファイル: ${files.length} 件(${[
|
|
218
|
+
`既定の除外 ${alwaysExcludedCount} 件`,
|
|
219
|
+
...filterParts,
|
|
220
|
+
`その他の除外 ${skipped.length} 件`,
|
|
221
|
+
].join("、")})`,
|
|
185
222
|
},
|
|
186
223
|
],
|
|
224
|
+
filtered,
|
|
187
225
|
};
|
|
188
226
|
}
|
|
227
|
+
/** 拡張子(小文字。ドット付き)。拡張子の無いもの・ドットで始まる名前はファイル名 */
|
|
228
|
+
function labelOf(relativePath) {
|
|
229
|
+
const name = path.posix.basename(relativePath);
|
|
230
|
+
const ext = path.posix.extname(name);
|
|
231
|
+
return ext === "" || ext === name ? name : ext.toLowerCase();
|
|
232
|
+
}
|
|
@@ -247,6 +247,18 @@ function describePath(source, node, rootDir) {
|
|
|
247
247
|
treeNote: ` → ${physical}`,
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
+
/** 「.csv 2 件 / .ipynb 1 件」(先頭 5 種類 + 残りの種類の数) */
|
|
251
|
+
function formatLabelCounts(entries) {
|
|
252
|
+
const shown = entries.slice(0, 5).map((entry) => `${entry.label} ${entry.count} 件`);
|
|
253
|
+
const rest = entries.length - shown.length;
|
|
254
|
+
return [...shown, ...(rest > 0 ? [`ほか ${rest} 種類`] : [])].join(" / ");
|
|
255
|
+
}
|
|
256
|
+
/** グロブの一覧(先頭 5 件 + 残りの数) */
|
|
257
|
+
function formatPatterns(patterns) {
|
|
258
|
+
const shown = patterns.slice(0, 5);
|
|
259
|
+
const rest = patterns.length - shown.length;
|
|
260
|
+
return [...shown, ...(rest > 0 ? [`ほか ${rest} 件`] : [])].join(" / ");
|
|
261
|
+
}
|
|
250
262
|
/** relativePosix が generatedDirs のいずれかの配下なら、そのディレクトリを返す */
|
|
251
263
|
function generatedDirOf(relativePosix, generatedDirs) {
|
|
252
264
|
if (relativePosix === undefined) {
|
|
@@ -443,7 +455,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
443
455
|
fileSize: deps.fileSize,
|
|
444
456
|
ignoreReasonFor: deps.ignoreReasonFor,
|
|
445
457
|
shownElsewhere: options.gitFilesShownElsewhere,
|
|
446
|
-
});
|
|
458
|
+
}, { include: options.gitInclude, exclude: options.gitExclude });
|
|
447
459
|
diagnostics.push(...extra.diagnostics);
|
|
448
460
|
skipped.push(...extra.skipped.map((s) => ({ path: s.relativePath, reason: s.reason })));
|
|
449
461
|
}
|
|
@@ -646,9 +658,27 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
646
658
|
]
|
|
647
659
|
: []),
|
|
648
660
|
...(extra !== undefined && gitFiles !== undefined
|
|
649
|
-
?
|
|
650
|
-
|
|
651
|
-
|
|
661
|
+
? extra.filtered === undefined
|
|
662
|
+
? [
|
|
663
|
+
`- 対象は git が管理しているファイル(追跡中のものと、.gitignore に一致しない未追跡のもの)。バイナリ・ロックファイル・${GIT_FILE_MAX_BYTES / 1024}KB を超えるもの・node_modules / dist / build / .env などは除外(<skipped_files> に理由)。対象を絞るときは .repomixignore に書く`,
|
|
664
|
+
]
|
|
665
|
+
: [
|
|
666
|
+
`- 対象は git が管理しているファイル(追跡中のものと、.gitignore に一致しない未追跡のもの)のうち、${configFileName} の include に一致し exclude に一致しないもの。バイナリ・ロックファイル・${GIT_FILE_MAX_BYTES / 1024}KB を超えるもの・node_modules / dist / build / .env なども除外(<skipped_files> に理由)`,
|
|
667
|
+
...(extra.filtered.notIncluded > 0 || extra.filtered.excluded > 0
|
|
668
|
+
? [
|
|
669
|
+
`- 設定で入れていないファイル: ${[
|
|
670
|
+
...(extra.filtered.notIncluded > 0
|
|
671
|
+
? [
|
|
672
|
+
`include に一致しない ${extra.filtered.notIncluded} 件(${formatLabelCounts(extra.filtered.notIncludedByLabel)})`,
|
|
673
|
+
]
|
|
674
|
+
: []),
|
|
675
|
+
...(extra.filtered.excluded > 0
|
|
676
|
+
? [`exclude(${formatPatterns(options.gitExclude ?? [])})に一致する ${extra.filtered.excluded} 件`]
|
|
677
|
+
: []),
|
|
678
|
+
].join("、")}。中身が必要なら、推測せずに共有を依頼すること`,
|
|
679
|
+
]
|
|
680
|
+
: []),
|
|
681
|
+
]
|
|
652
682
|
: []),
|
|
653
683
|
...(extra !== undefined && gitFiles === undefined
|
|
654
684
|
? [
|
|
@@ -697,8 +727,10 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
697
727
|
uiSummaryCount,
|
|
698
728
|
extraRootFileCount,
|
|
699
729
|
contractSummaryIncluded: contractPlaced,
|
|
730
|
+
gitFilesFiltered: gitFiles !== undefined ? extra?.filtered : undefined,
|
|
700
731
|
diagnostics,
|
|
701
732
|
filePaths,
|
|
702
733
|
environmentBlock,
|
|
703
734
|
};
|
|
704
735
|
}
|
|
736
|
+
export { formatLabelCounts };
|
|
@@ -242,6 +242,32 @@ function parseDocsConfig(value, fileName, diagnostics) {
|
|
|
242
242
|
};
|
|
243
243
|
return { design: pick("design"), spec: pick("spec"), handoff: pick("handoff") };
|
|
244
244
|
}
|
|
245
|
+
/** トップレベルの include / exclude(git が管理しているファイルの絞り込み) */
|
|
246
|
+
function parseGitFilters(parsed, fileName, diagnostics) {
|
|
247
|
+
const read = (key) => {
|
|
248
|
+
const value = parsed[key];
|
|
249
|
+
if (value === undefined) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
const list = asStringArray(value);
|
|
253
|
+
if (list === undefined) {
|
|
254
|
+
diagnostics.push({
|
|
255
|
+
severity: "warning",
|
|
256
|
+
message: `${fileName}: ${key} は文字列の配列で指定してください(無視します)`,
|
|
257
|
+
});
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
return list.map((glob) => normalizeGlobPath(glob.trim())).filter((glob) => glob !== "");
|
|
261
|
+
};
|
|
262
|
+
const include = read("include");
|
|
263
|
+
const exclude = read("exclude");
|
|
264
|
+
return {
|
|
265
|
+
present: parsed["include"] !== undefined || parsed["exclude"] !== undefined,
|
|
266
|
+
// 空の include は「何も入れない」ではなく指定なしとみなす(extraRoots の include と同じ)
|
|
267
|
+
include: include !== undefined && include.length > 0 ? include : undefined,
|
|
268
|
+
exclude: exclude ?? [],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
245
271
|
/** `kind`: "solution" / "generic"。それ以外は警告して既定の "solution" */
|
|
246
272
|
function parseKind(value, fileName, diagnostics) {
|
|
247
273
|
if (value === undefined) {
|
|
@@ -296,6 +322,7 @@ export function loadSlnmixConfig(rootDir, deps) {
|
|
|
296
322
|
const config = {
|
|
297
323
|
kind: "solution",
|
|
298
324
|
extraRoots: [],
|
|
325
|
+
exclude: [],
|
|
299
326
|
generatedDirs: [],
|
|
300
327
|
sources: [],
|
|
301
328
|
};
|
|
@@ -343,7 +370,23 @@ export function loadSlnmixConfig(rootDir, deps) {
|
|
|
343
370
|
}
|
|
344
371
|
}
|
|
345
372
|
config.extraRoots = parseExtraRoots(parsed["extraRoots"], fileName, diagnostics);
|
|
346
|
-
// generic で extraRoots が無ければ、git が管理しているファイルを対象にする(設計書 §25.7)
|
|
373
|
+
// generic で extraRoots が無ければ、git が管理しているファイルを対象にする(設計書 §25.7)。
|
|
374
|
+
// include / exclude はそのときだけ使う
|
|
375
|
+
const filters = parseGitFilters(parsed, fileName, diagnostics);
|
|
376
|
+
if (filters.present) {
|
|
377
|
+
if (config.kind === "generic" && config.extraRoots.length === 0) {
|
|
378
|
+
config.include = filters.include;
|
|
379
|
+
config.exclude = filters.exclude;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
diagnostics.push({
|
|
383
|
+
severity: "warning",
|
|
384
|
+
message: config.kind === "generic"
|
|
385
|
+
? `${fileName}: include / exclude は extraRoots が無いとき(git が管理しているファイルを対象にするとき)だけ使います。extraRoots では各要素の include / exclude に書いてください(無視します)`
|
|
386
|
+
: `${fileName}: include / exclude は kind: "generic" のときだけ使います(無視します)`,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
347
390
|
config.docs = parseDocsConfig(parsed["docs"], fileName, diagnostics);
|
|
348
391
|
const schema = asString(parsed["contractSchema"]);
|
|
349
392
|
if (schema !== undefined && schema.trim() !== "") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tazuna",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Build with AI chat, without handing over the reins: pack your codebase for the chat, then verify and apply its patches locally (zero dependencies; formerly petari and slnmix)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|