@kousaku-maron/diffshape 0.7.0 → 0.9.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 +3 -2
- package/dist/bin/{chunk-O2FOVHLS.js → chunk-KGUYHIRU.js} +20 -4
- package/dist/bin/dbshape.js +1 -1
- package/dist/bin/depshape.js +1 -1
- package/dist/bin/diffshape.js +1 -1
- package/dist/bin/fileshape.js +1 -1
- package/dist/bin/ui/assets/index-kQSL8wBb.js +161 -0
- package/dist/bin/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/bin/ui/assets/index-DBg_McNT.js +0 -166
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ npx @kousaku-maron/diffshape . main --merge-base
|
|
|
35
35
|
| `diffshape abc1234` | そのコミット単体の変更 |
|
|
36
36
|
| `diffshape staged` / `diffshape working` | ステージ済み / 未ステージの変更のみ |
|
|
37
37
|
|
|
38
|
-
オプション: `--merge-base`、`--schema <glob>`(スキーマの SQL ファイル。省略時はリポジトリ内のすべての `atlas.hcl` の `src` を読みます。DB が複数あるときは `--schema billing=services/billing/**/*.sql` のように名前を付けます)、`--only <file|dep|db>`、`--port <n>`(デフォルト 4977、使用中なら +1)、`--host`、`--no-open
|
|
38
|
+
オプション: `--merge-base`、`--schema <glob>`(スキーマの SQL ファイル。省略時はリポジトリ内のすべての `atlas.hcl` の `src` を読みます。DB が複数あるときは `--schema billing=services/billing/**/*.sql` のように名前を付けます)、`--only <file|dep|db>`、`--port <n>`(デフォルト 4977、使用中なら +1)、`--host`、`--no-open`、`--clean`(この比較のレビューコメントと確認済みのマークを消してから開く)
|
|
39
39
|
|
|
40
40
|
サーバーはデフォルトで `127.0.0.1` だけで待ち受け、`localhost` / `127.0.0.1` 宛て以外のリクエストは拒否します。`--host 0.0.0.0` などを指定すると、同じネットワークの他の端末からリポジトリの構成とスキーマが見えるので注意してください。
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ npx @kousaku-maron/diffshape . main --merge-base
|
|
|
43
43
|
|
|
44
44
|
- **左のアイコンバー**: 「ファイル」「依存」「DB」を切り替えます。アイコンの数字は変更の件数、青い点は未対応のコメントがあることを示します。読むものがないモジュール(SQL ファイルがないリポジトリの DB など)は薄く表示します。表示中のモジュールは URL(`#file` / `#dep` / `#db`)に残るので、再読み込みしても同じ画面が開きます
|
|
45
45
|
- **ヘッダー**: 比較の対象、「AI 用にコピー」、「AI」(下の「AI レビューと修正」)、「再読み込み」。切り替えても、各モジュールで開いていた箱・選んだテーブル・書きかけのコメントはそのまま残ります
|
|
46
|
-
- **AI 用にコピー**: すべてのモジュールの未対応のコメントを、1
|
|
46
|
+
- **AI 用にコピー**: すべてのモジュールの未対応のコメントを、difit と同じ素朴な形でコピーします。モジュールごとの見出し(`## ファイルの差分` / `## 依存関係` / `## DB スキーマ`)の下に、1行目が指す先(ファイルは `path:L12`、依存は `元 → 先`、DB は `定義の場所 対象の名前`)、続けて本文を並べ、コメント同士は `=====` で区切ります。コミット同士の比較では先頭に `diff main..feature` が付きます。指示文は付けないので、どうするかは貼った先で伝えます
|
|
47
47
|
- **再読み込み**: AI がファイルを書き換えたあとに、すべてを解析し直します。開いていた状態はそのまま残ります
|
|
48
48
|
- **DB が複数ある monorepo**: DB モジュールの中で DB を切り替えます(`atlas.hcl` ごと、または名前付きの `--schema` ごと)
|
|
49
49
|
|
|
@@ -60,6 +60,7 @@ npx @kousaku-maron/diffshape . main --merge-base
|
|
|
60
60
|
- **エージェント・モデル・Effort** は、レビュー用と修正用を別々に選べます(Codex にレビューさせて Claude Code に直させる、など)。モデルと Effort の一覧は、入っている CLI から読みます。選ばなければ CLI の設定どおりです
|
|
61
61
|
- **範囲**: 表示中の画面だけか、すべての画面か。依存の画面では追加した import やファイルに、DB の画面ではテーブル・カラム・制約などにコメントが付きます
|
|
62
62
|
- **レビューは読むだけ**(`claude -p --permission-mode plan` / `codex exec --sandbox read-only`)、**修正は編集とコマンドの実行を許して**起動します(`--permission-mode auto` / `--sandbox workspace-write`)。確認なしで全部を通すオプションは使いません
|
|
63
|
+
- **プロンプトは最小限です**: diffshape が伝えるのは、読むだけにすること、答えの形、コメントがどこを指すかといった、画面にコメントを置くのに要ることだけです。修正には「AI 用にコピー」と同じ一覧を渡し、先頭に「各指摘に対応してください」と進め方を足します。コメントの書き方(言葉づかい、署名など)は、リポジトリの `AGENTS.md` / `CLAUDE.md` に書いてください。エージェントはそれに従います
|
|
63
64
|
- **修正の前の状態は残ります**: 修正を始める前の作業ディレクトリを `refs/diffshape/before-fix` に取っておきます(作業ディレクトリとステージ済みの状態は変えません)。`diffshape . refs/diffshape/before-fix` で AI が変えた分だけを見られ、`git restore --source=refs/diffshape/before-fix --worktree -- <path>` でファイルを戻せます
|
|
64
65
|
- **起動できるのはこの画面からだけ**です。別のサイトのページからのリクエストでは始まらず、`--host` でほかの端末に公開しているときは、AI の機能そのものを止めます
|
|
65
66
|
- `claude` / `codex` が PATH にないときは、環境変数 `DIFFSHAPE_CLAUDE` / `DIFFSHAPE_CODEX` に実行ファイルのパスを指定できます
|
|
@@ -205,6 +205,16 @@ async function resolveSources(cwd, opts) {
|
|
|
205
205
|
}
|
|
206
206
|
return { root, target, base, targetLabel, baseLabel };
|
|
207
207
|
}
|
|
208
|
+
function compareRange(opts, s) {
|
|
209
|
+
if (s.target.kind !== "rev" || s.base.kind !== "rev") return null;
|
|
210
|
+
const target = opts.target === "@" ? "HEAD" : opts.target ?? ".";
|
|
211
|
+
const base = opts.base ? opts.base === "@" ? "HEAD" : opts.base : `${target}^`;
|
|
212
|
+
const sep = opts.base && opts.mergeBase ? "..." : "..";
|
|
213
|
+
const short = (rev) => rev.slice(0, 7);
|
|
214
|
+
const named = (name, rev) => /^[0-9a-f]{7,40}$/.test(name) && rev.startsWith(name);
|
|
215
|
+
const commits = named(base, s.base.rev) && named(target, s.target.rev) ? "" : ` (${short(s.base.rev)}..${short(s.target.rev)})`;
|
|
216
|
+
return `diff ${base}${sep}${target}${commits}`;
|
|
217
|
+
}
|
|
208
218
|
|
|
209
219
|
// ../core/src/server.ts
|
|
210
220
|
import { spawn as spawn2 } from "node:child_process";
|
|
@@ -2976,10 +2986,12 @@ var App = class {
|
|
|
2976
2986
|
this.opts = opts;
|
|
2977
2987
|
this.analyzers = analyzers;
|
|
2978
2988
|
this.jobs = new AgentJobs(appOpts.agents ?? true);
|
|
2989
|
+
this.cleanId = appOpts.clean ? `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 7)}` : null;
|
|
2979
2990
|
}
|
|
2980
2991
|
sources;
|
|
2981
2992
|
results = /* @__PURE__ */ new Map();
|
|
2982
2993
|
jobs;
|
|
2994
|
+
cleanId;
|
|
2983
2995
|
/** Resolves the comparison (errors like an unknown revision are thrown) and starts every module */
|
|
2984
2996
|
async refresh() {
|
|
2985
2997
|
this.sources = await resolveSources(this.cwd, this.opts);
|
|
@@ -2996,7 +3008,7 @@ var App = class {
|
|
|
2996
3008
|
}
|
|
2997
3009
|
info() {
|
|
2998
3010
|
const { root, targetLabel, baseLabel, base } = this.sources;
|
|
2999
|
-
return { repoRoot: root, targetLabel, baseLabel, baseRev: base.kind === "rev" ? base.rev : null, modules: this.analyzers.map((a) => a.id) };
|
|
3011
|
+
return { repoRoot: root, targetLabel, baseLabel, baseRev: base.kind === "rev" ? base.rev : null, range: compareRange(this.opts, this.sources), modules: this.analyzers.map((a) => a.id), clean: this.cleanId };
|
|
3000
3012
|
}
|
|
3001
3013
|
result(id) {
|
|
3002
3014
|
return this.results.get(id) ?? Promise.resolve({ error: `unknown module: ${id}` });
|
|
@@ -3060,7 +3072,8 @@ var COMMON = ` --merge-base compare-with \u3068 target \u306E\u5206\u5C90
|
|
|
3060
3072
|
--port <n> \u30DD\u30FC\u30C8\u756A\u53F7\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8 4977\u3001\u4F7F\u7528\u4E2D\u306A\u3089 +1\uFF09
|
|
3061
3073
|
--host <host> \u5F85\u3061\u53D7\u3051\u30DB\u30B9\u30C8\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8 127.0.0.1\u30020.0.0.0 \u306A\u3069\u306B\u3059\u308B\u3068\u540C\u3058\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u304B\u3089
|
|
3062
3074
|
\u30EA\u30DD\u30B8\u30C8\u30EA\u306E\u69CB\u6210\u304C\u898B\u3048\u308B\u306E\u3067\u6CE8\u610F\uFF09
|
|
3063
|
-
--no-open \u30D6\u30E9\u30A6\u30B6\u3092\u81EA\u52D5\u3067\u958B\u304B\u306A\u3044
|
|
3075
|
+
--no-open \u30D6\u30E9\u30A6\u30B6\u3092\u81EA\u52D5\u3067\u958B\u304B\u306A\u3044
|
|
3076
|
+
--clean \u3053\u306E\u6BD4\u8F03\u306E\u30EC\u30D3\u30E5\u30FC\u30B3\u30E1\u30F3\u30C8\u3068\u78BA\u8A8D\u6E08\u307F\u306E\u30DE\u30FC\u30AF\u3092\u6D88\u3057\u3066\u304B\u3089\u958B\u304F`;
|
|
3064
3077
|
var SCHEMA = ` --schema <glob> \u30B9\u30AD\u30FC\u30DE\u306E SQL \u30D5\u30A1\u30A4\u30EB\uFF08\u8907\u6570\u6307\u5B9A\u53EF\uFF09\u3002\u7701\u7565\u6642\u306F\u30EA\u30DD\u30B8\u30C8\u30EA\u5185\u306E\u3059\u3079\u3066\u306E atlas.hcl \u306E src \u3092\u8AAD\u3080
|
|
3065
3078
|
DB \u304C\u8907\u6570\u3042\u308B\u3068\u304D\u306F --schema billing=services/billing/**/*.sql \u306E\u3088\u3046\u306B\u540D\u524D\u3092\u4ED8\u3051\u308B`;
|
|
3066
3079
|
var HELP = {
|
|
@@ -3131,7 +3144,7 @@ function parseArgs(argv, command) {
|
|
|
3131
3144
|
const fail = (msg) => {
|
|
3132
3145
|
throw new UsageError(msg);
|
|
3133
3146
|
};
|
|
3134
|
-
const args = { port: 4977, host: "127.0.0.1", open: true, json: false, text: false, color: !!process.stdout.isTTY && !process.env.NO_COLOR, schema: [], only: fixed };
|
|
3147
|
+
const args = { port: 4977, host: "127.0.0.1", open: true, clean: false, json: false, text: false, color: !!process.stdout.isTTY && !process.env.NO_COLOR, schema: [], only: fixed };
|
|
3135
3148
|
const positional = [];
|
|
3136
3149
|
const allowed = (opt, ok) => ok || fail(`\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: ${opt}`);
|
|
3137
3150
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -3154,6 +3167,9 @@ function parseArgs(argv, command) {
|
|
|
3154
3167
|
case "--no-open":
|
|
3155
3168
|
args.open = false;
|
|
3156
3169
|
break;
|
|
3170
|
+
case "--clean":
|
|
3171
|
+
args.clean = true;
|
|
3172
|
+
break;
|
|
3157
3173
|
case "--schema":
|
|
3158
3174
|
allowed(a, !fixed || fixed === "db");
|
|
3159
3175
|
args.schema.push(argv[++i] ?? fail("--schema \u306B\u306F glob \u304C\u5FC5\u8981\u3067\u3059"));
|
|
@@ -3203,7 +3219,7 @@ async function run(command, argv) {
|
|
|
3203
3219
|
}
|
|
3204
3220
|
const all = [fileAnalyzer, depAnalyzer, dbAnalyzer({ schema: args.schema })];
|
|
3205
3221
|
const analyzers = args.only ? all.filter((a) => a.id === args.only) : all;
|
|
3206
|
-
const app = new App(process.cwd(), args, analyzers, { agents: isLoopback(args.host) });
|
|
3222
|
+
const app = new App(process.cwd(), args, analyzers, { agents: isLoopback(args.host), clean: args.clean });
|
|
3207
3223
|
try {
|
|
3208
3224
|
await app.refresh();
|
|
3209
3225
|
if (args.json || args.text) {
|
package/dist/bin/dbshape.js
CHANGED
package/dist/bin/depshape.js
CHANGED
package/dist/bin/diffshape.js
CHANGED