@kousaku-maron/diffshape 0.8.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 CHANGED
@@ -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つのプロンプトにまとめてコピーします(ファイルは `path:L12` とその行のコード、依存は import の状態と既存の依存のパターン、DB は SQL ファイルの定義位置つき)。Claude Code / Codex などにそのまま貼れます
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";
@@ -2998,7 +3008,7 @@ var App = class {
2998
3008
  }
2999
3009
  info() {
3000
3010
  const { root, targetLabel, baseLabel, base } = this.sources;
3001
- return { repoRoot: root, targetLabel, baseLabel, baseRev: base.kind === "rev" ? base.rev : null, modules: this.analyzers.map((a) => a.id), clean: this.cleanId };
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 };
3002
3012
  }
3003
3013
  result(id) {
3004
3014
  return this.results.get(id) ?? Promise.resolve({ error: `unknown module: ${id}` });
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-QXDXARRR.js";
4
+ } from "./chunk-KGUYHIRU.js";
5
5
 
6
6
  // src/bin/dbshape.ts
7
7
  void run("dbshape", process.argv.slice(2));
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-QXDXARRR.js";
4
+ } from "./chunk-KGUYHIRU.js";
5
5
 
6
6
  // src/bin/depshape.ts
7
7
  void run("depshape", process.argv.slice(2));
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-QXDXARRR.js";
4
+ } from "./chunk-KGUYHIRU.js";
5
5
 
6
6
  // src/bin/diffshape.ts
7
7
  void run("diffshape", process.argv.slice(2));
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-QXDXARRR.js";
4
+ } from "./chunk-KGUYHIRU.js";
5
5
 
6
6
  // src/bin/fileshape.ts
7
7
  void run("fileshape", process.argv.slice(2));