IronWordとChatGPT Codexの使い方
会社が社名を変更する際、法務チームは更新するための契約書ファイルを受け取ります。 古い名前は本文段落、パーティテーブル、大文字のタイトル、ページヘッダーに見つかります。 Wordは、複数の書式ランで名前を保持できます。たとえば、数年前に強調表示された部分がある場合です。 各ファイルで標準の検索と置換を行うと、いくつかのケースは修正されますが、変更されないままのものもあり、警告は出ません。
ChatGPT CodexはOpenAIのコードエージェントです。 リポジトリ内でファイルを編集し、dotnet runのようなコマンドを実行し、その変更をまとめます。 1つのエージェントがターミナル、IDE、ChatGPTデスクトップアプリケーション、およびクラウドタスクに対応します。 IronWordはIron Softwareが提供する.NETライブラリで、Microsoft Officeを使用せずに、コードが編集および保存できる段落、ラン、テーブルのオブジェクトモデルとして既存のWord文書を開きます。
Codexは真実のマニフェストを使用して契約のバックログを処理します。各契約ごとに1行のCSVを作成するプロンプトがあり、Codexからの報告がすべてファイルにバックアップされています。
クイックスタートCodexを契約フォルダを含む.NETコンソールプロジェクトで開始し、編集の前に在庫を依頼します。
$ironword Add the IronWord 2026.10.4 NuGet package to this console project.
Then have Program.cs open every .docx in Contracts/sample/ without changing it.
For each file, write one row to out/quickstart.csv with these columns:
- file
- body count, how often "Northwind Traders" appears in the body text
- table count, the same name counted separately in every table cell
- the exception type, when the file fails to open
Print the totals by reading that CSV back.
Program.cs reads the key from IRONWORD_LICENSE_KEY itself.
Don't print the key's value, and don't list environment variables.
Nothing gets saved here, so an unset key is no reason to stop.
Build and run it with at most three repair attempts, then tell me the result.
最小限のワークフロー(5ステップ)
- NuGetからC# Wordライブラリをダウンロード
- IronWordのスキルを.agents/skills/ironword/SKILL.mdとして保存して、
$ironwordが解決するようにします。 - オリジナルを読み取り専用としてマークし、すべてのカウントのためにCSVが必要なことをAGENTS.mdにコミットします。
- 最初にすべての場所をインベントリしてから、本文と大文字のタイトルのテキストを置換し、各変更されたテーブルセルを新しいもので置換します。
- 保存されたコピーを再スキャンし、いかなる状態を受け入れる前にマニフェストと結果ファイルを比較してください。
ChatGPT Codexとは何か、および.NET Wordドキュメント作業にどのように関連するか?
インストール手順はCodex CLIドキュメントにあり、リリースはオープンソースリポジトリに公開されています。
CodexはIronWordをトレーニングデータや提供されたファイルから知っており、新しいリリースは両方を最新でない状態にする可能性があります。 2026.10のリリースはストリームと非同期呼び出しを通じてロードおよび保存します。
IronWordプロンプトを書いてCodexを設定する方法は?
効果的なバッチプロンプトには、入力、名前の各場所、出力、証明、読み取り専用の真実、および制約が含まれています。
OpenAIの言語モデルが幻覚を引き起こす理由に関する論文は、トレーニングおよび評価によって間違った答えが自信をもって出される理由を探り、リネームの作業では、すべての契約がクリーンであると仮定される理由を説明しています。
Codexは作業ディレクトリとリポジトリルートの間のすべてのディレクトリ内の.agents/skillsにスキルを探します。 .agents/skills/IronWord/SKILL.mdとして保存されたIronWordのskill.mdが$ironwordのメンションを解決します。
どの作業の前にでも、Codexはリポジトリルートと作業フォルダの間のパスの各ディレクトリで最大1つのAGENTS.mdを読みます。 作業フォルダに最も近いファイルが優先されます。 /initコマンドは開始用のAGENTS.mdを作成します。
Give this repository a top-level AGENTS.md with a Contract rebrand section.
List these rules in it:
- No DOCX library other than IronWord is allowed.
- IronWord's package is IronWord, and its namespaces are IronWord and IronWord.Models.
- The ironword skill in .agents/skills/ironword/ is one API reference.
- https://ironsoftware.com/word/csharp/llms.txt is the other.
- Contracts/inbox/ and Contracts/manifest.csv are read-only.
- Rebranded copies go to out/rebranded/ under their original names.
- IRONWORD_LICENSE_KEY holds the key, and its value never appears in output, logs or files.
- Checking the variable means its presence and length, nothing more.
- Any count you report is read from a CSV written in the same turn.
- The reply names that CSV.
CodexにIronWordを追加し、ライセンスを確認するように依頼する方法は?
Print the IronWord PackageReference from ContractRebrand.csproj and the version restore resolved.
Then quote every IronSoftware entry that dotnet list package --include-transitive prints.
Leave the package references exactly as they are.
IronWord 2026.10.4はIronSoftware.Abstractions 2026.1.2、IronSoftware.Common 2026.4.2、IronSoftware.System.Drawing 2026.11.3を参照します。リスト内のIronSoftware.Drawing.Abstractions 2026.1.2も復元されます。ビルドはWindows、Linux、macOS用のネイティブLayoutEngineInteropライブラリをruntimesフォルダにコピーします。 OpenXMLの競合ページは、2025.7.13より前のリリースでの新しいDocumentFormat.OpenXmlとの競合について説明しています。ピンを設定する前にIronWordの変更履歴を確認してください。
キーがない場合、開く、読み取る、置換するが成功しますが、すべての保存オーバーロード(非同期も含む)がLicensingExceptionをスローし、メッセージはProduction License Requiredです。
Add Startup.ApplyIronWordKey and call it first in Program.cs.
It copies the IRONWORD_LICENSE_KEY value into IronWord.License.LicenseKey.
It also reports whether License.IsLicensed is true.
Add a --dry-run switch that opens and edits in memory and never saves.
Then run the sample twice with the variable removed:
1. Run it once with --dry-run.
2. Run it once copying each file to out/licence-check/ through SaveAs.
Clear the variable inside each child process only, never for the session.
Write out/licence-check.csv with the columns run, file, call, exception type name and message.
Tell me which calls threw.
The licensing exception type isn't public, so catch Exception and record its GetType().FullName.
Stop after three repair attempts.
ライセンスキーのページには、Web.config、App.config、およびappsettings.jsonについても説明されています。
Wordドキュメントのどの部分にテキスト置換が到達するか?
Create Services/MentionScanner.cs.
For one DOCX it returns a count for each of these:
- "Northwind Traders" in body paragraphs
- "Northwind Traders" in table cells
- the name in upper case
- the name inside "Northwind Traders Pension Trust"
- the name in headers and footers
- the old notice address
- the Fax notices paragraph
The body and table cell counts leave out the pension trust name.
IronWord has no header or footer model.
For that column only, read word/header*.xml and word/footer*.xml with System.IO.Compression.
Then run it over Contracts/inbox/ into out/inventory.csv.
Mark files that fail to open as Unreadable.
List every file whose counts differ from manifest.csv.
In that comparison, the body count is body_mentions plus split_run_mentions.
組み込みのエクスプローラーエージェントは、実際のファイルで置換をテストします。
Create a scratch console project under scratch/replace-probe/ yourself.
Add a Compile Remove line for scratch/** to ContractRebrand.csproj.
Then ask the explorer agent to use that project.
It finds which parts of a contract the document-level ReplaceText call changes.
It tests copies of the Contracts/sample/ files in memory, with these four cases:
- a name split across runs
- a table cell
- the upper-case title
- the pension trust
The header has no object in the API, so the explorer answers that one from IronWord.xml.
It changes nothing under Services/ or in Program.cs.
Write the five answers to out/replace-reach.csv.
Beside each answer, quote the ironword skill or IronWord documentation.
Where a page and the test disagree, say so.
2026.10.4でのキャリブレーションはこれらのメモリ内結果を示しました。
| 位置 | ドキュメントレベルの置換 | それに到達する部分 |
|---|---|---|
| 本文、一つのラン | 置換済み | ドキュメント呼び出し |
| 本文、ランをまたがって分割 | 置換済み | ドキュメント呼び出し |
| 表セル | 変更なし | 各TableCellでReplaceText |
| 大文字のタイトル | 変更なし(大文字と小文字を区別した一致) | 大文字の形式で2回目の呼び出し |
| 年金信託名 | 名前変更済み(単純なサブストリング一致) | プレースホルダーが最初に置換され、後で復元されました |
| ヘッダーまたはフッター | オブジェクトモデルにはありません | 報告してから手動で編集してください |
分割ランの行には副作用があります。太字の North に続けて通常書式の wind Traders として保存された名前が、Contoso Ltd. と読める 1 つの太字のランになります。
ドキュメントのExtractTextに基づいたチェックは、本文段落のみを返すため、パーティテーブルがまだ古い会社名を持つ契約を通過します。 FindTextはフレーズ全体を保持するテキスト要素にのみ一致するため、分割ラン一致を逃します。
フォルダ内のドキュメント全体でテキストを置換する方法は?
Have the worker agent write Services/Rebrander.cs.
It applies every rule in Contracts/README.md to Contracts/inbox/.
It builds on the explorer's findings and follows these rules:
- Replace inside each table cell as well as the body.
- Keep the pension trust intact.
- Delete the Fax notices paragraph.
- Leave header and footer parts as they are, since IronWord can't edit them.
- Report those contracts as HeaderFlagged.
- Save each copy to out/rebranded/ with SaveAs.
- Never call Save() on a document opened from inbox/.
Add a --sequential mode that rescans the saved copies with MentionScanner.
It writes out/sequential.csv with these columns:
- file
- status from the README, always one of its four
- mentions left per location
- milliseconds
- header_lost, set to yes when a copy lacks a header or footer part its original had
The header_lost column is reported on its own and never changes a status.
Tell me the status counts.
IronWord 2026.10.4では、テーブルを含む読み込まれたDOCXを保存すると、テーブル内のすべてのテキスト編集や最初のテーブル以降の段落が失われます。 ディスク上のコピーは古いテキストを保持し、例外は発生せず、メモリ内のドキュメントには置換が表示され続けます。 最初のテーブル前の編集は保持され、新しいTableCellで置換されたセルも保持されます。 これらの契約は署名をパーティテーブルの後に配置するため、メモリ内のチェックでは保存された署名が変更されないコピーを通過します。
パラメータレスのSaveは読み込まれたドキュメントのソースファイルを上書きすると文書化されていますので、バッチはそれを呼び出さないほうが良いです。 テキスト削除ガイドはファックスルールの背後にある段落削除を示しています。
校正中、ゼロバイトファイルを読み込むとNullReferenceExceptionがスローされ、テキストファイル、切り詰められたパッケージ、ランダムバイトのパッケージはいずれも、File contains corrupted dataというメッセージを持つ難解な名前空間からFileFormatExceptionをスローしました。 System.IO型のキャッチがそれを見逃します。 ファイルごとにExceptionをキャッチし、その型を記録します。
コピーはSaveAsを使用し、IronWordの保存後に消えるヘッダーに関するトラブルシューティングページで名前が付けられています。
Check whether SaveAs lost a header anywhere in this backlog.
IronWord's troubleshooting page header-disappears-after-saveas reports that in one environment.
For every HeaderFlagged file, compare the inbox original with its out/rebranded/ copy.
Look at the word/header*.xml and word/footer*.xml parts.
Write out/header-check.csv with these columns:
- file
- header parts before
- header parts after
- whether each part is present with its text unchanged
If a part went missing, rebrand that contract again from its inbox original.
Write it with the Save overload that takes the out/rebranded/ path.
Don't use the parameterless Save().
If the part is still missing, record it and stop.
Tell me which files lost a part.
フォルダ内のドキュメントを並列に処理する方法は?
非同期呼び出しは、ブロックすることなくファイルI/Oを行いますが、解析とシリアル化は同期のままであると文書化されており、1つのドキュメントインスタンスはスレッドセーフではありません。
Add a --parallel mode that works like this:
- It runs Task.WhenAll over the inbox.
- Each task holds a slot of a SemaphoreSlim whose size comes from --concurrency.
- Then it awaits WordDocument.LoadAsync and SaveAsAsync on its own WordDocument.
Run the mode three times:
1. At concurrency 1 into out/parallel-c1/.
2. At concurrency 4 into out/parallel-c4/.
3. At Environment.ProcessorCount into out/parallel-max/.
Write out/parallel-compare.csv with the columns file, folder and a yes or no.
The yes or no says whether the extracted body and cell text match out/rebranded/.
Log each run as a new line of out/runs.csv.
Give it the mode, concurrency, elapsed seconds and match count from out/parallel-compare.csv.
Tell me the quickest setting in runs.csv.
校正中、未読可能な4つのファイルを含むインボックスをメモリ内で開いて編集するのに、逐次的には4.8秒を要し、上限が4で1.4秒、16で1.8秒かかり、SaveAsAsyncを追加すると14.4、5.5、4.7秒でした。 保存は制約のあるステップです。
古いテキストが現れるドキュメントを診断する方法は?
Codexは-iフラグ(--image)を新しいセッションで、またはcodex exec resumeで画像を受け入れるか、または作曲者にペーストすることで受け入れます。
I attached the first page of out/rebranded/MSA-1050.docx as an image with -i.
Its header still names Northwind Traders.
Look at the image, then explain from the file itself why the batch left that text.
Tell me whether out/sequential.csv already flags this file.
Don't change any code.
正しい答えはヘッダー部分とファイルのHeaderFlagged行を指摘します。
不正なバッチ出力を端から端までデバッグする方法は?
Find out why the nightly job passed contracts that legal later flagged.
The log reports 0 contracts still naming Northwind Traders.
Contracts/legal-review.csv lists contracts where legal still found the old name.
It was in the party table or an upper-case title.
The file also lists a pension trust that was renamed.
Send the explorer agent through Jobs/NightlyRebrand.cs and Logs/nightly-2026-10-07/ first.
Then write your own report in out/nightly-diagnosis.md with these parts:
- why the job's own check passed them
- the smallest fix
- the command that proves the fix
Don't run or edit any code.
診断はジョブが契約をクリーンとマークする行を引用する必要があります。
一度限りのコードを再利用可能でテスト済みのコンポーネントに変えるにはどうすればよいですか?
Put the worker agent on a RebrandJob class, built like this:
- Install the Microsoft.Extensions.DependencyInjection package.
- Have its container resolve RebrandJob.
- Set it up through a RebrandOptions record with inbox, output folder, concurrency and dry run.
- Keep every README rule, the header check and the per-file CSV.
- RebrandJob.cs stays under 180 lines, with XML doc comments.
The README rules cover body and cell replacement, upper case and the pension trust guard.
They also cover the address and the fax deletion.
Run the job over the whole inbox into out/final/ and out/final.csv.
Then tell me whether every status matches manifest.csv.
Also confirm no copy keeps an old name, old address or fax paragraph.
Old names in a copy's header or in the pension trust don't count.
リファクタリングはルールを削除しつつ、ビルドを維持できます。
Add an xUnit project at tests/ContractRebrand.Tests.
Exclude it from the main project's compile items, and join both projects in a solution file.
Write tests on real inbox files that check these:
- a split-run contract comes back with no old name
- a table contract is clean in its cells
- a pension trust mention survives
- a header contract is HeaderFlagged
- the zero-byte file is Unreadable without stopping the batch
- 20 files rebranded in parallel equal their sequential copies
Assert on extracted text and statuses, never on DOCX bytes.
Keep test copies in out/tests/work/.
Run dotnet test on the solution with a trx logger into out/tests/.
Report the totals from the trx file.
OpenAIのカスタムプロンプトのドキュメントは、~/.codex/promptsに保存されたプロンプトをスキルの方が適切で、繰り返しの質問が属する場所に移行することを提唱します。
$ironword Look in the installed IronWord.xml.
List the WordDocument members that load or save a document, and answer these:
- Which ones are asynchronous?
- Which one overwrites the source file a document was loaded from?
List only members you can call from a line that compiles in a probe under scratch/.
Also name any member anywhere in IronWord.xml that is documented but doesn't compile.
Check by compiling only.
Don't run Save() on any document loaded from Contracts/inbox/.
Then show the line in RebrandJob that keeps Contracts/inbox/ untouched.
これらのプロンプトを他のドキュメントバックログで再利用する方法は?
名前、パス、ルールを変更することでこれらのプロンプトが次のバックログに合い、IronWord AIコーディングアシスタントガイドがすべてのアシスタントのセットアップをカバーします。
プロンプトが実運用で生成したものは何ですか?
プロンプトは1つのCodexセッションで順番に実行されました。 .NET 9プロジェクトには124の契約があり、期待されるステータスとカウントのマニフェストがあり、すべてのReleaseビルドが成功しました。 私たちのスキャナーはすべての保存されたコピーを再スキャンし、テストは新しいクローンで再実行されました。
- リネームの前に、インベントリは124のファイルすべてのマニフェストと一致し、4つの非DOCXファイルをUnreadableとマークしました。
- 逐次的なブランド変更の後、保存された120のコピーはパーティーテーブル上の114の古い名前を保持せず、22分割してランしたものを含みました。
- 13の大文字のタイトル、38の古い通知アドレス、57のファックス段落はすべて残っていませんでした。
- 9つの年金信託名はすべて無傷のままでした。
- 古い名前は28のパーティテーブルと114の署名に残り、保存操作がそれらの編集を破棄したためです。
- ワーカーのsequential.csvは各ファイルにマニフェストのステータスを、Rebranded 104、HeaderFlagged 10、NoChange 6、Unreadable 4と与えましたが、独自のカウント列にはまだ114の署名と28のテーブル言及が表示されていました。 ステータスはCodex自身が報告したように、置換ではなく検出を記録します。
- 10のサンプルファイルでは、クイックスタートがマニフェストに対して本文で19、テーブルで2の言及を報告し、それに対して16と2を示しました。本文カウントは2セルの言及と年金信託名も取り込みました。
- キーなしで、ドライランはすべての9つの読み取れるサンプルファイルをメモリ内で編集しました。 保存ランは各ファイルのSaveAsでLicensingExceptionをスローしました。
- 1、4、32で並列ランは11.456、7.825、5.830秒を要しました。 各フォルダのすべての120の読み取れるコピーは逐次的なコピーと一致しました。
- 夜間の診断は、ジョブの大文字小文字を区別するExtractText().Containsチェックとドキュメントレベルの置換に発見が遡ったことを示しました。 行番号は示されず、その証拠コマンドはまだ存在しないテストプロジェクトを対象にしていました。
- リファクタリングは68行のRebrandJob.csにすべてのルールを保持し、そのout/finalコピーはout/rebrandedと一致しました。
- final.csvはマニフェストのステータスと一致しましたが、118行を不完全とマークし、Codexはコンテンツチェックが失敗したと報告しました。
- Codexのランと新しいクローンはそれぞれ6つのテストのうち4つに合格しました。 分割ランテストは署名で失敗し、テーブルテストはパーティーテーブルのセルで失敗しました。
- APIの答えは4つのロード、7つのセーブ、5つの非同期メンバーをリストし、パラメータレスのSaveをソースを上書きするものとして指定しました。
- 正しく4つの文書化されたメンバーを名前で指定し、コンパイルされないこれらは、バイトと文字列を受け取るコンストラクター、FlushModelToBytes、段落でのReplaceTextAcrossRuns、およびSetNoChangeStatusAsUpdatedでした。
- またバイトのみのコンストラクターもリストし、これはコンパイルしますが、2026.10.4で失敗する5つの他のFromMarkdown、FromMarkdownFile、ExportToMarkdownFile、GetMailMergeWorkingBytes、およびテーブルでのApplyCellStyleを見逃しました。
- 一部のステップはページと異なる方法で実行されました。 画像はラン中のMSA-1050コピーからpython-docxでレンダリングされました。 夜間の仕事、そのログ、および法的レビューのファイルは調査プロンプトの直前に追加されました。
GitHub Copilotガイドは、テーブル、行、セルを通してそのテーブルを読み取ることで保存されたステートメントをテストします。 カーソルガイドは、IronWordが読み取らないDOCXの部分をリストします。
共有実行記録には、Codexのバージョン、モデル、マシン、そしてこの実行のタイミングがリストされています。
トラブルシューティング
- Wordドキュメントのテキストを置換するに関する段落レベルでの
ReplaceTextおよびFindText - 保存後にヘッダーが消える保存後にヘッダーが消える
- ビルドがOpenXML SDKも参照する場合のDocumentFormat.OpenXmlとIronWord
- IronWordがWeb.configにストアされたキーを無視する場合に備えたIronWordライセンスのweb.config
質問ありますか?
質問がある場合は、support@ironsoftware.com にお問い合わせください。
Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。