petfishframework 0.1.0__tar.gz

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.
Files changed (115) hide show
  1. petfishframework-0.1.0/.env.example +23 -0
  2. petfishframework-0.1.0/.github/workflows/ci.yml +33 -0
  3. petfishframework-0.1.0/.gitignore +48 -0
  4. petfishframework-0.1.0/AGENTS.md +370 -0
  5. petfishframework-0.1.0/AGENTS.md.new +100 -0
  6. petfishframework-0.1.0/CHANGELOG.md +61 -0
  7. petfishframework-0.1.0/CONTRIBUTING.md +89 -0
  8. petfishframework-0.1.0/LICENSE +21 -0
  9. petfishframework-0.1.0/PKG-INFO +151 -0
  10. petfishframework-0.1.0/README.md +128 -0
  11. petfishframework-0.1.0/conftest.py +10 -0
  12. petfishframework-0.1.0/docs/api.md +989 -0
  13. petfishframework-0.1.0/docs/architecture.md +255 -0
  14. petfishframework-0.1.0/docs/benchmark-results.md +202 -0
  15. petfishframework-0.1.0/docs/development.md +7 -0
  16. petfishframework-0.1.0/docs/research/competitor-analysis/README.md +97 -0
  17. petfishframework-0.1.0/docs/research/competitor-analysis/competitor-matrix.md +180 -0
  18. petfishframework-0.1.0/docs/research/competitor-analysis/market-brief.md +118 -0
  19. petfishframework-0.1.0/docs/research/competitor-analysis/positioning-map.md +107 -0
  20. petfishframework-0.1.0/docs/research/competitor-analysis/swot-analysis.md +60 -0
  21. petfishframework-0.1.0/docs/research/literature-review/inclusion-exclusion-criteria.md +55 -0
  22. petfishframework-0.1.0/docs/research/literature-review/literature-matrix.md +70 -0
  23. petfishframework-0.1.0/docs/research/literature-review/literature-review.md +157 -0
  24. petfishframework-0.1.0/docs/research/literature-review/search-strategy.md +68 -0
  25. petfishframework-0.1.0/docs/research/reference-repos-absorption.md +256 -0
  26. petfishframework-0.1.0/docs/skeleton-completeness-checklist.md +98 -0
  27. petfishframework-0.1.0/docs/test-results-report.md +93 -0
  28. petfishframework-0.1.0/docs/usage-guide.md +868 -0
  29. petfishframework-0.1.0/docs/validation-roadmap.md +279 -0
  30. petfishframework-0.1.0/initialization-report.md +91 -0
  31. petfishframework-0.1.0/mcp/README.md +7 -0
  32. petfishframework-0.1.0/mcp/connection-checklist.md +7 -0
  33. petfishframework-0.1.0/mcp/mcp-config.example.json +27 -0
  34. petfishframework-0.1.0/opencode.json +67 -0
  35. petfishframework-0.1.0/pyproject.toml +68 -0
  36. petfishframework-0.1.0/qa/code-review-checklist.md +7 -0
  37. petfishframework-0.1.0/qa/qa-review.md +104 -0
  38. petfishframework-0.1.0/qa/qc-gate-decision.md +51 -0
  39. petfishframework-0.1.0/qa/test-plan.md +7 -0
  40. petfishframework-0.1.0/src/petfishframework/__init__.py +33 -0
  41. petfishframework-0.1.0/src/petfishframework/config.py +142 -0
  42. petfishframework-0.1.0/src/petfishframework/core/__init__.py +91 -0
  43. petfishframework-0.1.0/src/petfishframework/core/agent.py +207 -0
  44. petfishframework-0.1.0/src/petfishframework/core/compiled.py +89 -0
  45. petfishframework-0.1.0/src/petfishframework/core/contracts.py +190 -0
  46. petfishframework-0.1.0/src/petfishframework/core/conversation.py +51 -0
  47. petfishframework-0.1.0/src/petfishframework/core/environment.py +260 -0
  48. petfishframework-0.1.0/src/petfishframework/core/events.py +79 -0
  49. petfishframework-0.1.0/src/petfishframework/core/session.py +182 -0
  50. petfishframework-0.1.0/src/petfishframework/core/structured.py +202 -0
  51. petfishframework-0.1.0/src/petfishframework/core/types.py +192 -0
  52. petfishframework-0.1.0/src/petfishframework/mcp/__init__.py +19 -0
  53. petfishframework-0.1.0/src/petfishframework/mcp/client.py +96 -0
  54. petfishframework-0.1.0/src/petfishframework/mcp/server.py +14 -0
  55. petfishframework-0.1.0/src/petfishframework/mcp/stdio_transport.py +218 -0
  56. petfishframework-0.1.0/src/petfishframework/mcp/wrapper.py +43 -0
  57. petfishframework-0.1.0/src/petfishframework/models/__init__.py +14 -0
  58. petfishframework-0.1.0/src/petfishframework/models/anthropic.py +194 -0
  59. petfishframework-0.1.0/src/petfishframework/models/fake.py +202 -0
  60. petfishframework-0.1.0/src/petfishframework/models/openai.py +178 -0
  61. petfishframework-0.1.0/src/petfishframework/observability/__init__.py +10 -0
  62. petfishframework-0.1.0/src/petfishframework/observability/sinks.py +23 -0
  63. petfishframework-0.1.0/src/petfishframework/permissions/__init__.py +32 -0
  64. petfishframework-0.1.0/src/petfishframework/permissions/model.py +110 -0
  65. petfishframework-0.1.0/src/petfishframework/reasoning/__init__.py +13 -0
  66. petfishframework-0.1.0/src/petfishframework/reasoning/lats.py +222 -0
  67. petfishframework-0.1.0/src/petfishframework/reasoning/llm_plus_p.py +202 -0
  68. petfishframework-0.1.0/src/petfishframework/reasoning/react.py +176 -0
  69. petfishframework-0.1.0/src/petfishframework/reliability/__init__.py +78 -0
  70. petfishframework-0.1.0/src/petfishframework/reliability/cost.py +50 -0
  71. petfishframework-0.1.0/src/petfishframework/reliability/cost_report.py +101 -0
  72. petfishframework-0.1.0/src/petfishframework/reliability/pass_at_k.py +232 -0
  73. petfishframework-0.1.0/src/petfishframework/reliability/replay.py +190 -0
  74. petfishframework-0.1.0/src/petfishframework/reliability/retry.py +224 -0
  75. petfishframework-0.1.0/src/petfishframework/reliability/timeout.py +55 -0
  76. petfishframework-0.1.0/src/petfishframework/retrieval/__init__.py +12 -0
  77. petfishframework-0.1.0/src/petfishframework/retrieval/adaptive.py +137 -0
  78. petfishframework-0.1.0/src/petfishframework/retrieval/crag.py +135 -0
  79. petfishframework-0.1.0/src/petfishframework/retrieval/memory_store.py +72 -0
  80. petfishframework-0.1.0/src/petfishframework/tools/__init__.py +12 -0
  81. petfishframework-0.1.0/src/petfishframework/tools/agent_tool.py +47 -0
  82. petfishframework-0.1.0/src/petfishframework/tools/base.py +75 -0
  83. petfishframework-0.1.0/src/petfishframework/tools/calculator.py +84 -0
  84. petfishframework-0.1.0/src/petfishframework/tools/path_planner.py +90 -0
  85. petfishframework-0.1.0/src/petfishframework/tools/registry.py +158 -0
  86. petfishframework-0.1.0/src/petfishframework/tools/word_sorter.py +41 -0
  87. petfishframework-0.1.0/tasks/backlog.md +28 -0
  88. petfishframework-0.1.0/tests/integration/__init__.py +6 -0
  89. petfishframework-0.1.0/tests/integration/test_anthropic_integration.py +50 -0
  90. petfishframework-0.1.0/tests/integration/test_openai_integration.py +113 -0
  91. petfishframework-0.1.0/tests/test_agent_tool.py +156 -0
  92. petfishframework-0.1.0/tests/test_anthropic_adapter.py +179 -0
  93. petfishframework-0.1.0/tests/test_api_agent_lifecycle.py +188 -0
  94. petfishframework-0.1.0/tests/test_api_edge_cases.py +159 -0
  95. petfishframework-0.1.0/tests/test_api_integration.py +337 -0
  96. petfishframework-0.1.0/tests/test_api_public_surface.py +123 -0
  97. petfishframework-0.1.0/tests/test_api_type_safety.py +154 -0
  98. petfishframework-0.1.0/tests/test_async.py +169 -0
  99. petfishframework-0.1.0/tests/test_conversation.py +161 -0
  100. petfishframework-0.1.0/tests/test_m2_m3_m4.py +262 -0
  101. petfishframework-0.1.0/tests/test_mcp.py +180 -0
  102. petfishframework-0.1.0/tests/test_openai_adapter.py +191 -0
  103. petfishframework-0.1.0/tests/test_pass_at_k.py +119 -0
  104. petfishframework-0.1.0/tests/test_replay.py +199 -0
  105. petfishframework-0.1.0/tests/test_retrieval.py +147 -0
  106. petfishframework-0.1.0/tests/test_retry.py +241 -0
  107. petfishframework-0.1.0/tests/test_skeleton.py +145 -0
  108. petfishframework-0.1.0/tests/test_stdio_transport.py +166 -0
  109. petfishframework-0.1.0/tests/test_streaming.py +100 -0
  110. petfishframework-0.1.0/tests/test_structured.py +127 -0
  111. petfishframework-0.1.0/tests/test_tool_registry.py +201 -0
  112. petfishframework-0.1.0/tests/test_v2_interface_compatibility.py +102 -0
  113. petfishframework-0.1.0/tests/test_v2_lats.py +85 -0
  114. petfishframework-0.1.0/tests/test_v2_llm_plus_p.py +68 -0
  115. petfishframework-0.1.0/uv.lock +1458 -0
@@ -0,0 +1,23 @@
1
+ # petfishFramework — Environment Variables
2
+ #
3
+ # Copy this file to .env and fill in your values:
4
+ # cp .env.example .env
5
+ #
6
+ # All variables are optional — the framework works without them (FakeModel for testing).
7
+ # Integration tests and benchmarks require at least one provider's key.
8
+
9
+ # ── OpenAI (or OpenAI-compatible provider) ──────────────────────────────────
10
+ # For SiliconFlow or other OpenAI-compatible APIs, set base_url accordingly.
11
+
12
+ OPENAI_API_KEY=sk-your-key-here
13
+ OPENAI_BASE_URL=https://api.siliconflow.cn/v1
14
+
15
+ # ── Anthropic ───────────────────────────────────────────────────────────────
16
+ # ANTHROPIC_API_KEY=sk-ant-your-key-here
17
+
18
+ # ── Benchmark / Integration Test Model ──────────────────────────────────────
19
+ # The model name to use for integration tests and benchmarks.
20
+ # SiliconFlow examples: Qwen/Qwen2.5-72B-Instruct, deepseek-ai/DeepSeek-V3
21
+ # OpenAI examples: gpt-4o-mini, gpt-4o
22
+
23
+ BENCHMARK_MODEL=Qwen/Qwen2.5-72B-Instruct
@@ -0,0 +1,33 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master, main]
6
+ pull_request:
7
+ branches: [master, main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v3
21
+
22
+ - name: Set up Python ${{ matrix.python-version }}
23
+ run: uv python install ${{ matrix.python-version }}
24
+
25
+ - name: Install dependencies
26
+ run: uv sync --all-extras
27
+
28
+ - name: Lint with ruff
29
+ run: uv run ruff check src/ tests/
30
+
31
+ - name: Run tests
32
+ run: uv run pytest tests/ -q --tb=short
33
+ # Integration tests are skipped automatically (no API key in CI)
@@ -0,0 +1,48 @@
1
+ # OS
2
+ Thumbs.db
3
+ Desktop.ini
4
+ .DS_Store
5
+
6
+ # Editors
7
+ .vscode/
8
+ .idea/
9
+ *.swp
10
+ *.swo
11
+
12
+ # Python
13
+ __pycache__/
14
+ *.pyc
15
+ .venv/
16
+
17
+ # Environment secrets — NEVER commit
18
+ .env
19
+ .env.*
20
+ !.env.example
21
+ .uv/
22
+
23
+ # Installed skills — derived from packs, regenerated by the installer.
24
+ # Source of truth is the skill pack repo; installed copies must not be tracked.
25
+ .opencode/skills/
26
+ .opencode/commands/
27
+ .opencode/agents/
28
+ .opencode/installed-packs.json
29
+ .claude/skills/
30
+ .claude/installed-packs.json
31
+ .cursor/skills/
32
+ .cursor/installed-packs.json
33
+ .github/skills/
34
+ .github/installed-packs.json
35
+ .windsurf/skills/
36
+ .windsurf/installed-packs.json
37
+ .agents/skills/
38
+ .agents/installed-packs.json
39
+
40
+ # PetFish local state
41
+ .petfish/
42
+
43
+ # Temp/backup files
44
+ *.bak
45
+ extract.py
46
+ install_extracted.py
47
+ .opencode/mcp/
48
+ .opencode/plugin/
@@ -0,0 +1,370 @@
1
+ # petfishFramework — Project Agent Guide
2
+
3
+ ## 项目目标
4
+
5
+ 构建一个通用 AI Agent 框架,让用户能够轻松对接各种模型,并便捷地接入自己的 RAG、MCP 及其他文档或工具。
6
+
7
+ ## 项目类型
8
+
9
+ code(框架开发)
10
+
11
+ ## 当前阶段
12
+
13
+ 前期调研 → 核心抽象 → 设计(同步测试用例)→ 开发 → QA/QC → Alpha 内测
14
+
15
+ ## 工作原则
16
+
17
+ - 理解目标后再行动;大规模修改前先提方案。
18
+ - 不覆盖现有文件,除非明确确认;不删除文件,除非明确要求。
19
+ - 调研阶段:所有结论必须可追溯(evidence ledger + source)。
20
+ - 设计阶段:测试用例与设计同步产出(TDD)。
21
+ - 开发阶段:未经 QA 的代码不进入 alpha。
22
+ - 网络操作失败时至少重试两次再换方案(瞬时故障常见)。
23
+ - 不写入密钥、API key、token、密码、私钥或生产凭证。
24
+ - 不将已安装的 skill/command/agent 派生文件纳入版本控制(加入 `.gitignore`)。
25
+
26
+ ## 目录地图
27
+
28
+ ```text
29
+ src/ 框架核心代码
30
+ tests/ 测试(与设计同步,TDD)
31
+ docs/ 架构文档、API 文档、开发文档
32
+ examples/ 使用示例
33
+ configs/ 配置模板
34
+ mcp/ MCP 集成模板
35
+ qa/ QA 检查清单
36
+ scripts/ 工具脚本
37
+ outputs/ 生成输出(与源码分离)
38
+ tasks/ 任务与 backlog
39
+ .opencode/ AI agent 技能与配置
40
+ ```
41
+
42
+ ## 偏好工具
43
+
44
+ - uv — Python 项目管理
45
+ - pytest — 测试
46
+ - ruff — lint
47
+ - mypy — 类型检查(可选)
48
+ - drawio — 架构图
49
+ - MCP filesystem server — 受控项目访问
50
+
51
+ ## 质量门禁
52
+
53
+ - README 清晰说明项目目标与用法。
54
+ - 存在 tasks / 路线图。
55
+ - 存在 QA 检查清单。
56
+ - 生成输出与源码分离。
57
+ - 开发项目有测试或测试计划。
58
+
59
+ ## Development Gotchas
60
+
61
+ <!--
62
+ 记录代码库中非代码自解释的约定、已知陷阱、关键设计约束。
63
+ 规则:每条必须是"违反会导致 bug,且代码本身无法自解释"的约束;上限 10 条。
64
+ -->
65
+
66
+ ## Architecture Decisions
67
+
68
+ <!-- 重大技术选型和设计决策的简要记录(一句话结论 + 指向 docs/ 下完整 ADR 的链接)。 -->
69
+
70
+ ## Crystallization Triggers
71
+
72
+ 经验沉淀在以下时机评估是否有新 gotcha 需记录:
73
+ - 完成架构审查并修复问题后
74
+ - 修复了"看起来不是 bug 但其实是"的问题后
75
+ - 新增模型适配器 / RAG 后端 / MCP 集成点后
76
+
77
+ ---
78
+
79
+ <!-- 以下为已安装 skill pack 的路由规则(由 PEtFiSh 安装器注入,请勿手动修改) -->
80
+
81
+ <!-- BEGIN pack: opencode-skill-pack-testcases-usage-docs -->
82
+ # Test Cases & Usage Docs Skill Pack Rules
83
+
84
+ This pack provides two complementary skills: generating test cases from real project code, and generating usage documentation from real project capabilities.
85
+
86
+ ## Skill Routing (强制)
87
+
88
+ ### Rules
89
+
90
+ 1. When the user asks to generate **test cases, test strategy, test matrix, or test plan** from a project, **MUST** route to `generate-test-cases`. Do NOT route to `generate-usage-docs`.
91
+ 2. When the user asks to generate **README, Quick Start, API docs, CLI docs, FAQ, or troubleshooting guides** from a project, **MUST** route to `generate-usage-docs`. Do NOT route to `generate-test-cases`.
92
+ 3. Both skills require a **project inventory step first**: run `uv run scripts/project_inventory.py .` before generating artifacts. Do not skip this step.
93
+ 4. When the user asks for both tests and docs in the same request, run `generate-test-cases` and `generate-usage-docs` sequentially (inventory once, then both generation steps). Do not merge them into a single pass.
94
+ 5. Both skills operate on **real project code and design docs** — do not generate generic/template artifacts without first reading the actual project.
95
+
96
+ ### Conflict Resolution
97
+
98
+ - "Write tests for this project" = `generate-test-cases`.
99
+ - "Document this project" = `generate-usage-docs`.
100
+ - "Help me ship this project" (ambiguous) → ask whether the priority is test coverage or user-facing documentation, then route accordingly.
101
+ - If the user provides a design doc or spec as input, both skills can use it — but route based on the desired output type (tests vs docs).
102
+
103
+ ## generate-test-cases Workflow
104
+
105
+ 1. Run project inventory: `uv run scripts/project_inventory.py .`
106
+ 2. Build traceability map: capabilities → test targets
107
+ 3. Generate layered test artifacts:
108
+ - Test strategy (scope, risk areas, coverage goals)
109
+ - Test matrix (feature × scenario × priority)
110
+ - Test cases (input, expected output, pass/fail criteria)
111
+ 4. Output to `tests/` or designated output directory
112
+
113
+ ## generate-usage-docs Workflow
114
+
115
+ 1. Run project inventory: `uv run scripts/project_inventory.py .`
116
+ 2. Identify target audience (end user / developer / operator)
117
+ 3. Identify project capabilities (CLI, API, config, integrations)
118
+ 4. Build doc set:
119
+ - README (overview, install, quick start)
120
+ - API / CLI reference
121
+ - FAQ and troubleshooting
122
+ 5. Output to `docs/` or designated output directory
123
+
124
+ ## Behavioral Rules
125
+
126
+ - Always run project inventory before generating any artifact. Do not generate from assumptions.
127
+ - Test cases must be traceable to specific project capabilities identified in the inventory.
128
+ - Usage docs must reflect actual project behavior, not generic boilerplate.
129
+ - If the project inventory reveals missing or ambiguous capabilities, flag them before generating — do not silently fill gaps with invented behavior.
130
+ - Generated test cases must include: input, expected output, and pass/fail criteria. Vague test descriptions are not acceptable.
131
+ - Generated docs must include: at least one working example per capability documented.
132
+
133
+ ## Output Format
134
+
135
+ **generate-test-cases** outputs:
136
+ 1. Test strategy document — scope, risk areas, coverage goals
137
+ 2. Test matrix — feature × scenario × priority table
138
+ 3. Test case files — structured cases with input/output/criteria
139
+
140
+ **generate-usage-docs** outputs:
141
+ 1. README — overview, install, quick start
142
+ 2. Reference docs — API / CLI / config
143
+ 3. FAQ / Troubleshooting — common issues and resolutions
144
+ <!-- END pack: opencode-skill-pack-testcases-usage-docs -->
145
+
146
+ <!-- BEGIN pack: trustskills-governance-pack -->
147
+ # Trust Skills Governance Pack Rules
148
+
149
+ This pack provides skill trust scanning, governance level assignment, and manifest generation/verification for PEtFiSh skill packs.
150
+
151
+ ## Skill Routing (强制)
152
+
153
+ ### Rules
154
+
155
+ 1. When the user asks to **scan skills for trust, safety, or governance issues**, **MUST** route to `skill-trust-governance`.
156
+ 2. When the user asks to **generate or verify a trust manifest** for a skill or pack, **MUST** route to `skill-trust-governance`.
157
+ 3. When the user asks to **assign or review governance levels** (allow / allow_with_ask / sandbox_required / manual_review_required / deny) for skills, **MUST** route to `skill-trust-governance`.
158
+ 4. When the user asks to **redline** a skill (flag it as requiring manual review or denial), **MUST** route to `skill-trust-governance`.
159
+ 5. The entrypoint for all trust operations is: `uv run .opencode/skills/skill-trust-governance/scripts/trust_scan.py`. Do not invoke `trustskills` CLI directly without going through this entrypoint.
160
+
161
+ ### Conflict Resolution
162
+
163
+ - Trust governance vs security audit: `skill-trust-governance` handles **governance classification and manifest management** (what level of trust to grant a skill). `skill-security-auditor` handles **vulnerability and risk scanning** (what security risks a skill poses). They are complementary — run security audit first, then use findings to inform governance level assignment.
164
+ - When the user asks to "check if a skill is safe to install", route to `skill-security-auditor` for risk findings, then `skill-trust-governance` for governance decision.
165
+ - When the user asks to "publish a skill", the governance manifest must be generated by `skill-trust-governance` before the `quality-gate` publish flow.
166
+
167
+ ## Governance Levels
168
+
169
+ | Level | Meaning | Agent Behavior |
170
+ |---|---|---|
171
+ | `allow` | Trusted, no restrictions | Execute without prompting |
172
+ | `allow_with_ask` | Trusted but requires confirmation for sensitive actions | Prompt user before sensitive operations |
173
+ | `sandbox_required` | Must run in isolated environment | Do not execute outside sandbox |
174
+ | `manual_review_required` | Flagged for human review before use | Block execution, notify user |
175
+ | `deny` | Rejected, must not be used | Refuse to load or execute |
176
+
177
+ ## trust_scan.py Modes
178
+
179
+ - **scan**: Analyze a skill directory and produce a trust report
180
+ - **manifest**: Generate a signed trust manifest for a skill
181
+ - **verify**: Verify an existing trust manifest against current skill content
182
+ - **redline**: Flag a skill at `manual_review_required` or `deny` level
183
+
184
+ ## Behavioral Rules
185
+
186
+ - Never assign `allow` governance level without completing a full scan. Partial scans must result in `manual_review_required` at minimum.
187
+ - Trust manifests must be regenerated whenever skill content changes. Stale manifests are treated as `manual_review_required`.
188
+ - `deny`-level skills must not be loaded, executed, or referenced in routing rules.
189
+ - When a scan finds issues, report them with the specific governance level recommendation and the reason. Do not silently downgrade to `allow`.
190
+ - Governance decisions must be logged with: skill path, scan timestamp, findings summary, assigned level, and agent ID.
191
+
192
+ ## Output Format
193
+
194
+ **scan** output:
195
+ 1. Trust report — findings per skill file, risk signals detected
196
+ 2. Recommended governance level with justification
197
+
198
+ **manifest** output:
199
+ 1. Signed trust manifest file (saved alongside skill)
200
+ 2. Manifest summary — skill path, level, timestamp, hash
201
+
202
+ **verify** output:
203
+ 1. Verification result: PASS / FAIL / STALE
204
+ 2. If FAIL or STALE: diff of what changed and recommended action
205
+
206
+ **redline** output:
207
+ 1. Updated governance level in manifest
208
+ 2. Redline reason and required remediation steps before level can be upgraded
209
+ <!-- END pack: trustskills-governance-pack -->
210
+
211
+ <!-- BEGIN pack: project-initializer-skill -->
212
+ # Project Initializer Skill Pack Rules
213
+
214
+ This pack provides workspace scaffolding and initialization capabilities for AI-agent projects.
215
+
216
+ ## Skill Routing (强制)
217
+
218
+ ### Rules
219
+
220
+ 1. When the user asks to initialize, scaffold, bootstrap, or set up a new AI-agent workspace, **MUST** route to `project-initializer`.
221
+ 2. When the user asks to generate `AGENTS.md`, `README`, `.opencode/` templates, `docs/`, `tasks/`, `qa/`, or `mcp` config files, **MUST** route to `project-initializer`.
222
+ 3. When the user selects or asks about a profile (minimal / course / code / ops / security / research / writing / skills-package / comprehensive), **MUST** route to `project-initializer`.
223
+ 4. When the user asks to configure a `uv` dev environment for a new project, **MUST** route to `project-initializer`.
224
+ 5. **Safe no-overwrite rule**: `project-initializer` must check for existing files before writing. For any file that already exists, it must ask for explicit confirmation before overwriting. Never silently overwrite.
225
+
226
+ ### Conflict Resolution
227
+
228
+ - If the user asks to "update" or "modify" an existing `AGENTS.md` rather than initialize from scratch, do NOT route to `project-initializer` — handle as a direct edit task.
229
+ - If the user asks to initialize AND install packs, route initialization to `project-initializer` first, then route pack installation to `petfish-companion`.
230
+
231
+ ## Profiles
232
+
233
+ | Profile | Included Templates |
234
+ |---|---|
235
+ | minimal | AGENTS.md, README |
236
+ | course | + docs/, course structure, QA/QC templates |
237
+ | code | + tasks/, .opencode/agents/, dev env |
238
+ | ops | + deploy config, runbook templates |
239
+ | security | + security policy, threat model stubs |
240
+ | research | + research/, evidence/, sources/ stubs |
241
+ | writing | + docs/, style guide stub |
242
+ | skills-package | + packs/, skill scaffold, lint config |
243
+ | comprehensive | all of the above |
244
+
245
+ ## Behavioral Rules
246
+
247
+ - Always confirm the target directory and profile before writing any files.
248
+ - List all files that will be created before creating them (dry-run summary).
249
+ - For risky operations (overwrite existing files, delete, restructure), require explicit user confirmation.
250
+ - After scaffolding, output a post-init summary: files created, next steps, recommended pack installs.
251
+ - Do not create `README.md` files unless the profile explicitly includes them or the user requests them.
252
+
253
+ ## Output Format
254
+
255
+ Post-init output must include:
256
+
257
+ 1. **Files Created** — list of paths written
258
+ 2. **Skipped / Conflicts** — files that already existed and were not overwritten
259
+ 3. **Next Steps** — recommended commands (e.g., `/petfish install <pack>`, `uv sync`)
260
+ 4. **Profile Summary** — what the selected profile provides
261
+ <!-- END pack: project-initializer-skill -->
262
+
263
+ <!-- BEGIN pack: doc-reader-skill -->
264
+ # Doc Reader Skill Pack Rules
265
+
266
+ This pack provides unified document-to-Markdown conversion for reading, review, and extraction.
267
+
268
+ ## Skill Routing (强制)
269
+
270
+ ### Rules
271
+
272
+ 1. When the user wants to **read, extract text from, or convert** a non-Markdown document (PDF, DOCX, XLSX, HTML, EPUB) to Markdown, **MUST** route to `doc-reader`.
273
+ 2. When the user needs **structured text content** from a document (tables, paragraphs, lists), **MUST** use `doc-reader` to convert first, then read the Markdown output.
274
+ 3. For **PPTX files**: use `ppt-reader` for structural inventory (slide order, media, comments, layout), use `doc-reader` for full text extraction including tables and charts. Use both for complete PPTX understanding.
275
+ 4. When the user provides a document and asks to **review, summarize, or extract key points**, use `doc-reader` for conversion, then apply `reference-document-review` for analysis. Do NOT treat conversion as analysis.
276
+
277
+ ### Conflict Resolution
278
+
279
+ - "Read this PDF and summarize": route `doc-reader` (convert) → agent reads output → summarize. Conversion and analysis are separate steps.
280
+ - "Extract the tables from this DOCX": route `doc-reader` with `--json` for metadata, then read the Markdown output.
281
+ - "Read this PPTX": route `ppt-reader` first for structure, then `doc-reader` for full text if structural inventory is insufficient.
282
+ - "Convert this document to Markdown": route `doc-reader` only. No analysis needed.
283
+ - When `reference-document-review` is also installed: `doc-reader` handles conversion, `reference-document-review` handles analysis and extraction into course inputs. Do not merge these responsibilities.
284
+
285
+ ## doc-reader Workflow
286
+
287
+ 1. Identify input file and format (PDF, DOCX, XLSX, HTML, EPUB, etc.)
288
+ 2. Run conversion:
289
+ ```bash
290
+ uv run scripts/doc_to_markdown.py input.pdf --output output.md
291
+ ```
292
+ 3. Read the converted Markdown output
293
+ 4. Optionally extract structured metadata:
294
+ ```bash
295
+ uv run scripts/doc_to_markdown.py input.pdf --output output.md --json metadata.json
296
+ ```
297
+
298
+ ## Behavioral Rules
299
+
300
+ - Always convert before reading. Do NOT attempt to interpret binary file contents directly.
301
+ - Preserve the conversion output as a file when the user needs to review or cite it later. Use `--output` flag.
302
+ - For scanned PDFs, warn the user that markitdown does NOT perform OCR by default; text extraction will be minimal.
303
+ - For PPTX, always recommend `ppt-reader` for structural analysis first if structure matters (slide order, media inventory, layout issues).
304
+ - Do NOT attempt LLM-based image description through this skill. The agent can view images natively.
305
+
306
+ ## Output Format
307
+
308
+ **doc-reader** outputs:
309
+ 1. Markdown file — converted text content from the source document
310
+ 2. (Optional) JSON metadata — `{source_file, source_ext, text_length, title_guess}`
311
+ <!-- END pack: doc-reader-skill -->
312
+
313
+ <!-- BEGIN pack: opencode-ppt-skills -->
314
+ # PPT Skills Pack Rules
315
+
316
+ This pack provides PPTX reading and writing capabilities for course slides, proposals, reports, and technical decks.
317
+
318
+ ## Skill Routing (强制)
319
+
320
+ ### Rules
321
+
322
+ 1. When the user wants to **read, inspect, summarize, audit, or compare** a PPT/PPTX file, **MUST** route to `ppt-reader`. Do NOT route to `ppt-writer`.
323
+ 2. When the user wants to **create, rewrite, restructure, update, or export** a PPT/PPTX deck, **MUST** route to `ppt-writer`. Do NOT route to `ppt-reader`.
324
+ 3. When the user provides a Markdown outline, document, meeting notes, or old PPT and asks to generate a new deck, **MUST** route to `ppt-writer`.
325
+ 4. When the user asks for a "rewrite brief" or "per-slide action plan" as input for a future writing task, **MUST** route to `ppt-reader` (produces the brief), then `ppt-writer` (executes it).
326
+ 5. When the user asks for visual QA of a generated deck, **MUST** use `ppt-writer`'s `qa_deck.py` step — do NOT treat this as a `ppt-reader` task.
327
+
328
+ ### Conflict Resolution
329
+
330
+ - "Read and then rewrite" requests: route `ppt-reader` first to produce inventory + rewrite brief, then `ppt-writer` to execute. Do not merge into a single step.
331
+ - "Summarize the slides" = `ppt-reader`. "Update the slides" = `ppt-writer`.
332
+ - When ambiguous, ask: is the primary output a **report about** the deck (`ppt-reader`) or **a new deck** (`ppt-writer`)?
333
+
334
+ ## ppt-reader Workflow
335
+
336
+ 1. Extract slide inventory → `pptx_inventory.json` (titles, layout, notes, comments, media, links)
337
+ 2. Produce Markdown summary of structure and content
338
+ 3. Flag: missing placeholders, sensitive info, broken links, layout inconsistencies
339
+ 4. Optionally produce a rewrite brief / per-slide action plan for `ppt-writer`
340
+
341
+ ## ppt-writer Workflow
342
+
343
+ 1. Receive input: Markdown / doc / outline / old PPTX / rewrite brief
344
+ 2. Build narrative structure and page plan
345
+ 3. Run `build_deck.py` to generate PPTX
346
+ 4. Run `qa_deck.py` to verify output
347
+ 5. Fix issues found in QA
348
+ 6. Re-verify until QA passes
349
+ 7. Deliver final PPTX
350
+
351
+ ## Behavioral Rules
352
+
353
+ - Never skip the `qa_deck.py` step after `build_deck.py`. Generate → QA → fix → re-verify is mandatory.
354
+ - `ppt-reader` output (inventory JSON + Markdown summary) must be saved before passing to `ppt-writer`.
355
+ - Template and style unification must be applied consistently across all slides in a deck.
356
+ - Do not mix reading and writing in a single tool invocation.
357
+ - LibreOffice and Poppler are optional dependencies for visual QA; if unavailable, note the limitation and proceed with structural QA only.
358
+
359
+ ## Output Format
360
+
361
+ **ppt-reader** outputs:
362
+ 1. `pptx_inventory.json` — structured slide inventory
363
+ 2. Markdown summary — human-readable structure and content overview
364
+ 3. (Optional) Rewrite brief — per-slide action plan
365
+
366
+ **ppt-writer** outputs:
367
+ 1. Generated `.pptx` file
368
+ 2. QA report — issues found and fixed
369
+ 3. Delivery summary — slide count, template used, known limitations
370
+ <!-- END pack: opencode-ppt-skills -->
@@ -0,0 +1,100 @@
1
+ # Project Agent Guide
2
+
3
+ ## Project Goal
4
+
5
+ petfishFramework is an AI-agent-friendly project workspace initialized with the `code` profile.
6
+
7
+ ## Project Type
8
+
9
+ code
10
+
11
+ ## Working Principles
12
+
13
+ - Understand the goal before acting.
14
+ - Propose a plan before large-scale edits.
15
+ - Do not overwrite existing files unless explicitly confirmed.
16
+ - Do not delete files unless explicitly requested.
17
+ - Leave notes for important changes.
18
+ - When code is involved, prefer adding or updating tests.
19
+ - When operations are involved, preserve rollback and auditability.
20
+ - Never write secrets, API keys, tokens, passwords, private keys, or production credentials into repository files.
21
+ - Do not operate on other repositories (even with access); raise issues instead.
22
+ - When network operations fail (SSH, package install, git clone, API calls), retry at least twice before changing approach — transient failures are common.
23
+ - Do not track installed skill/command/agent files in version control — they are derived from the skill source (packs) and regenerated by the installer. Add platform skill directories to `.gitignore`.
24
+
25
+ ## Directory Map
26
+
27
+ ```text
28
+ Profile: code
29
+ Target: D:\MyWorkSpaces\petfishFramework
30
+ ```
31
+
32
+ ## Preferred Tools
33
+
34
+ - uv for Python project setup
35
+ - pytest for tests
36
+ - ruff for linting
37
+ - markdownlint for markdown checks
38
+ - drawio for architecture diagrams
39
+ - docker only when explicitly needed
40
+ - MCP filesystem server for controlled project access
41
+
42
+ ## Skills
43
+
44
+ Recommended skills:
45
+
46
+ - repo-reader
47
+ - code-reviewer
48
+ - test-case-generator
49
+ - dev-env-manager
50
+ - documentation-writer
51
+ - qa-reviewer
52
+
53
+ ## MCP
54
+
55
+ MCP configuration examples may be placed under `mcp/`. Use placeholders only. Do not commit real secrets.
56
+
57
+ ## Quality Gates
58
+
59
+ - README explains project goal and usage.
60
+ - Tasks or roadmap exist.
61
+ - QA checklist exists.
62
+ - Generated outputs are separated from sources.
63
+ - Development projects have tests or a test plan.
64
+
65
+ ## Do Not
66
+
67
+ - Do not write secrets.
68
+ - Do not hide shell commands.
69
+ - Do not overwrite user files silently.
70
+ - Do not mix temporary outputs into formal materials.
71
+ - Do not perform offensive security actions without explicit lawful authorization and isolated scope.
72
+
73
+ ## Development Gotchas
74
+
75
+ <!--
76
+ 记录代码库中非代码自解释的约定、已知陷阱、关键设计约束。
77
+ 规则:
78
+ - 每条必须是"违反会导致 bug,且代码本身无法自解释"的约束
79
+ - 上限 10 条;超过时审视哪些已通过代码改进不再需要
80
+ - 一次性排查过程不记录
81
+ -->
82
+
83
+ - 发现 `void this.xxx`、空方法体、`@ts-ignore` 等绕过模式时,视为架构缺陷而非有意设计,主动向用户报告
84
+ - 修改状态枚举时,同步更新转换守卫表;新增状态前确认调用方会设置它
85
+ - 新增平台适配器时,检查所有 IO 边界(消息发送、输出格式化、长度截断)是否有平台分发逻辑
86
+
87
+ ## Architecture Decisions
88
+
89
+ <!--
90
+ 重大技术选型和设计决策的简要记录。
91
+ 格式:一句话结论 + 指向 docs/ 下完整 ADR 的链接(如有)。
92
+ -->
93
+
94
+ ## Crystallization Triggers
95
+
96
+ 经验沉淀不在每次 commit 后触发。以下时机评估是否有新 gotcha 需记录:
97
+
98
+ - 完成架构审查并修复问题后
99
+ - 修复了"看起来不是 bug 但其实是"的问题后
100
+ - 新增平台/适配器/集成点后
@@ -0,0 +1,61 @@
1
+ # Changelog
2
+
3
+ All notable changes to petfishFramework will be documented in this file.
4
+
5
+ ## [0.1.0a1] — 2026-07-06 (Alpha)
6
+
7
+ ### Added — Core Framework
8
+ - **Agent + Session dual abstraction**: immutable recipe + event-sourced execution process
9
+ - **Environment chokepoint**: all model/tool/retrieval calls flow through single audited surface
10
+ - **3 reasoning strategies**: ReAct (default), LATS (MCTS search), LLM+P (symbolic planning)
11
+ - **3 model adapters**: OpenAI (lazy import), Anthropic, FakeModel (deterministic testing)
12
+ - **MCP integration**: real stdio transport, tool discovery, MCPToolWrapper
13
+ - **3 routing axes**: Adaptive-RAG (retrieval), ReasoningStrategy (reasoning), ToolRegistry (tools)
14
+
15
+ ### Added — Reliability
16
+ - **Pass^k**: freeze+perturb consistency metric (k-repetition + 5 perturbation variants)
17
+ - **ReplayMode**: AUDIT (deterministic replay), RESUME (checkpoint recovery), RERUN (fresh)
18
+ - **Budget enforcement**: hard limits on tokens, cost, steps, tool calls
19
+ - **Retry**: exponential backoff with jitter for transient failures
20
+ - **Timeout**: per-operation timeout via ThreadPoolExecutor
21
+
22
+ ### Added — Security
23
+ - **SARC access control**: Subject/Action/Resource/Context model
24
+ - **6 DecisionEffects**: ALLOW, DENY, MASK, PARTIAL_ALLOW, REQUIRE_APPROVAL, DEGRADE
25
+ - **Two-gate model**: visibility (CapabilityProjection) + invocation (authorize)
26
+
27
+ ### Added — Product Features
28
+ - Async support (dual sync/async interface)
29
+ - Streaming responses (Iterator[str])
30
+ - Conversation memory (cross-session, InMemoryConversationStore)
31
+ - Structured output (JSON → dataclass, zero regex)
32
+ - Multi-agent delegation (AgentAsTool)
33
+ - ToolRegistry + IntentRouter (automatic tool selection by task intent)
34
+ - Configuration system (FrameworkConfig from env/dict)
35
+ - Cost reporting (CostReport with per-model pricing)
36
+ - WordSorter tool (deterministic alphabetical sort)
37
+
38
+ ### Added — Documentation
39
+ - Architecture design (5 decisions, 3 resolved open questions)
40
+ - API reference (989 lines, test-validated)
41
+ - Usage guide (868 lines, 18 sections, full lifecycle)
42
+ - Benchmark results (Arithmetic + MMLU + BBH + Pass^k, 3-tier strategy)
43
+ - 3 runnable examples (quickstart, tools+retrieval, multi-agent)
44
+
45
+ ### Added — Retrieval
46
+ - MemoryRetriever (keyword-overlap, in-memory)
47
+ - CRAG (Corrective RAG: retrieval evaluation + web fallback)
48
+ - Adaptive-RAG (query complexity classification → routing)
49
+
50
+ ### Quality
51
+ - 187 tests (unit + integration), ruff clean
52
+ - 7 real-world bugs found and fixed through API validation
53
+ - Real MCP server validation (14 tools discovered)
54
+ - Real LLM validation (SiliconFlow OpenAI + Anthropic format)
55
+ - MIT License
56
+
57
+ ### Known Limitations (Alpha)
58
+ - Single model validated (Qwen-72B on SiliconFlow)
59
+ - No CI/CD pipeline yet
60
+ - Benchmark sample sizes limited by API speed
61
+ - API may change before v0.1.0 stable