Skip to content

chore: improve chapter 6-8 manuscript alignment#42

Merged
laiso merged 1 commit into
mainfrom
feature/align-chapter-6-code
May 25, 2026
Merged

chore: improve chapter 6-8 manuscript alignment#42
laiso merged 1 commit into
mainfrom
feature/align-chapter-6-code

Conversation

@laiso
Copy link
Copy Markdown
Owner

@laiso laiso commented May 24, 2026

Summary

  • 第6章の統合版 CLI を本書の構造(baseInstructions / issueDrivenInstructions / instructions: isIssueDriven ? ...)に寄せ直し、後続章(7章 GitHub連携、8章サンドボックス、付録機能)の要素が先に見える理由をコメントとサポートサイトに整理しました。
  • 第6章の Google provider について、LLM_API_KEY@google/genai SDK が自動参照する GEMINI_API_KEY に反映するよう修正し、回帰テストを追加しました。
  • 第7章の Issue 駆動ワークフローで、信頼済みの実行指示(ISSUE_BODY)と未信頼の Issue 本文(ISSUE_TEXT)を分離し、Prompt Injection 対策としてデリミタと注意書きを追加しました。
  • 第7章の Git / GitHub ツールと第8章の execCommandSandbox について、ツール description は本書の文言を維持し、安全補強(ブランチ名検証、git add --git commit -F--body-filevalidateTitle、危険パターン検知など)はコードコメントとサポートサイトで補足する形に整理しました。
  • サポートサイトに、6→7→8章を順に写経する読者向けの補足を追加しました。

Verification

  • bunx tsc --noEmit
  • bun test
  • git diff --check
  • execCommandSandboxcommandName / commandArgs 形式と危険パターン拒否のスモーク確認
  • Git / GitHub ツールの入力検証スモーク確認
  • ISSUE_BODY / ISSUE_TEXT の CLI 入力判定スモーク確認
  • .github/workflows/nano-code.yml の YAML パース確認
  • サポートサイトの追加アンカー確認

@laiso laiso temporarily deployed to secure-agent May 24, 2026 12:29 — with GitHub Actions Inactive
@laiso laiso force-pushed the feature/align-chapter-6-code branch from e6526b6 to e329517 Compare May 24, 2026 12:51
@laiso laiso temporarily deployed to secure-agent May 24, 2026 12:51 — with GitHub Actions Inactive
@laiso laiso force-pushed the feature/align-chapter-6-code branch from e329517 to f3371d0 Compare May 24, 2026 15:15
@laiso laiso temporarily deployed to secure-agent May 24, 2026 15:15 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

レビューしました。全体として、Issue 本文を未信頼入力として分離するワークフロー変更や、各 Provider で tool call / tool result の不整合を補正する方向性は実運用上の 400 エラー対策として良い改善だと思います。bun test も実行し、既存テストは pass していることを確認しました。

ただし、1 点ブロッカーがあります。

Must fix

src/core/prompt.ts が ESM 環境で起動時に壊れます

この PR で fileURLToPath(import.meta.url)path.dirname(__filename) による __dirname 定義が削除されていますが、package.json は ESM ("type": "module") のため、Node/Bun の ESM 実行時に CommonJS の __dirname は定義されません。

現在の実装では以下の行で ReferenceError: __dirname is not defined になり、loadInstructions() を通る CLI / review 実行が起動できなくなる可能性があります。

const basePath = path.resolve(__dirname, 'prompt.md');

コメントにも「ESM環境では __dirname が未定義」と書かれていますが、注意喚起ではなく実際に実行時エラーになります。元の実装に戻すか、例えば以下のように ESM 対応の __dirname を復元してください。

import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

あわせて、loadInstructions()prompt.md と workspace の AGENTS.md を読めることを確認するテストを追加すると、この種の回帰を防げると思います。

確認結果

  • bun test は pass しました。
  • ただし上記の loadInstructions() の ESM 起動経路は既存テストでカバーされていないようです。

この __dirname の回帰を修正すれば、他の変更は概ね良い方向だと思います。

@laiso laiso changed the title chore: align chapter 6 code implementation and prompt with book manus… chore: improve chapter 6-8 manuscript alignment May 24, 2026
@laiso laiso force-pushed the feature/align-chapter-6-code branch from f3371d0 to 3dbf91d Compare May 25, 2026 07:53
@laiso laiso temporarily deployed to secure-agent May 25, 2026 07:53 — with GitHub Actions Inactive
@laiso laiso force-pushed the feature/align-chapter-6-code branch from 3dbf91d to 0cc5dd5 Compare May 25, 2026 08:21
@laiso laiso temporarily deployed to secure-agent May 25, 2026 08:21 — with GitHub Actions Inactive
@laiso laiso force-pushed the feature/align-chapter-6-code branch from 0cc5dd5 to 89e1301 Compare May 25, 2026 08:33
@laiso laiso temporarily deployed to secure-agent May 25, 2026 08:33 — with GitHub Actions Inactive
- clarify integrated CLI differences across chapters 6, 7, and 8

- separate trusted issue tasks from untrusted ISSUE_TEXT in GitHub Actions

- document Git/GitHub and sandbox command hardening in code and support docs
@laiso laiso force-pushed the feature/align-chapter-6-code branch from 89e1301 to bc28613 Compare May 25, 2026 08:53
@laiso laiso merged commit e8bd5fb into main May 25, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant