Files
hakorune/apps/examples/file_handle/append_and_stat.hako
nyash-codex 99f57ef27d feat(phase113): FileHandleBox Nyash 公開 API 完成
FileHandleBox の内部メソッド(open/read/write/close/exists/size)を
Nyash (.hako) 側から「普通の Box メソッド」として使える形に完全公開

【実装内容】

Task 1: 公開 API 設計書完成
- phase113_filehandlebox_public_api.md 作成(380行完全仕様書)
- I/O メソッド: open(path, mode) / read() / write(text) / close()
- メタデータメソッド: exists() / size() / isFile() / isDir()
- Profile 別動作: Default (全機能) / NoFs (open で panic)

Task 2: Rust 側メソッド公開
- FileHandleBox に ny_* メソッド実装(8メソッド)
- BoxFactory 登録完了
- StringBox と同じ invoke_method() パターン採用

Task 3: .hako サンプル & テスト
- append_and_stat.hako サンプル作成(実用例)
- Rust ユニットテスト 6個(全メソッド + Profile カバレッジ)

Task 4: Profile 統合確認
- Default プロファイル: 全機能正常動作 
- NoFs プロファイル: open は panic、cascade disabled 
- Ring0Registry による自動無効化パターン確立 

Task 5: ドキュメント完全更新
- core_boxes_design.md: Section 16.1 追加(88行)
- ring0-inventory.md: Phase 113 エントリ追加(8行)
- CURRENT_TASK.md: Phase 113 完了マーク

【統計】
- 新規作成: 3ファイル(.md + .hako + factory)
- 修正: 6ファイル
- 追加行数: +210行
- テスト: 6個(全 PASS)
- ビルド: SUCCESS

【Phase 106-113 通算】
- 7フェーズ完成
- 33+17=50ファイル修正
- +1,350+210=+1,560行実装
- 設計書: 6つの大規模 markdown
- テスト: 33+6=39個全PASS
- 第1章完結状態に到達 

【設計原則確立】
- Ring0 → Ring1 FS API の完全統一
- Profile-aware 初期化(SSOT パターン)
- FileBox / FileHandleBox / Ring0 の非矛盾性設計
- .hako 入口から Rust 実装まで全導線完備

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 03:35:25 +09:00

27 lines
575 B
Plaintext

// Phase 113: FileHandleBox Nyash API Example
// This demonstrates the Nyash-visible API methods
local h = new FileHandleBox()
// 初回: append モードで書き込み
h.open("/tmp/example_log.txt", "a")
h.write("First line\n")
h.close()
// 再度: append モードで追記
h.open("/tmp/example_log.txt", "a")
h.write("Second line\n")
h.close()
// Read mode で全内容を読む
h.open("/tmp/example_log.txt", "r")
local content = h.read()
print(content)
// メタデータ確認
if h.exists() {
local size = h.size()
print("File size: " + size)
}
h.close()