guarantee-based-coding 0.2.2__tar.gz → 0.3.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 (111) hide show
  1. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/LICENSE +0 -0
  2. guarantee_based_coding-0.3.0/MANIFEST.in +3 -0
  3. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/PKG-INFO +115 -108
  4. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/README.md +9 -2
  5. guarantee_based_coding-0.3.0/build_support.py +29 -0
  6. guarantee_based_coding-0.3.0/docs/en/concepts.md +225 -0
  7. guarantee_based_coding-0.3.0/docs/en/onboarding-agent.md +114 -0
  8. guarantee_based_coding-0.3.0/docs/en/quick-start.md +154 -0
  9. guarantee_based_coding-0.3.0/docs/en/reference.md +238 -0
  10. guarantee_based_coding-0.3.0/docs/en/workflow.md +212 -0
  11. guarantee_based_coding-0.3.0/docs/zh/concepts.md +196 -0
  12. guarantee_based_coding-0.3.0/docs/zh/onboarding-agent.md +99 -0
  13. guarantee_based_coding-0.3.0/docs/zh/quick-start.md +143 -0
  14. guarantee_based_coding-0.3.0/docs/zh/reference.md +222 -0
  15. guarantee_based_coding-0.3.0/docs/zh/workflow.md +177 -0
  16. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/__init__.py +1 -1
  17. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/__init__.py +0 -0
  18. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/assets.py +16 -0
  19. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/config/__init__.py +0 -0
  20. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/config/backups.py +0 -0
  21. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/config/base.py +0 -0
  22. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/config/executor.py +0 -0
  23. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/config/project.py +0 -0
  24. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/core/__init__.py +0 -0
  25. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/core/env.py +0 -0
  26. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/core/executor.py +0 -0
  27. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/core/guarantee.py +12 -5
  28. guarantee_based_coding-0.3.0/gbc/app/documentation/__init__.py +3 -0
  29. guarantee_based_coding-0.3.0/gbc/app/documentation/base.py +109 -0
  30. guarantee_based_coding-0.3.0/gbc/app/documentation/cli.py +54 -0
  31. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/i18n/__init__.py +0 -0
  32. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/i18n/lang.py +0 -0
  33. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/i18n/translate.py +0 -0
  34. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/intent/__init__.py +0 -0
  35. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/intent/base.py +0 -0
  36. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/intent/cli.py +18 -18
  37. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/intent/editor.py +0 -0
  38. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/interface/__init__.py +0 -0
  39. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/interface/base.py +170 -1
  40. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/interface/cli.py +55 -4
  41. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/interface/mcp.py +67 -21
  42. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/models/__init__.py +0 -0
  43. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/models/errors.py +0 -0
  44. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/models/meta.py +0 -0
  45. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/models/verify.py +0 -0
  46. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/utils/__init__.py +0 -0
  47. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/utils/file_utils.py +0 -0
  48. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/utils/gbc_md.py +0 -0
  49. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/utils/json_model_operator.py +0 -0
  50. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/app/utils/safe_file_writer.py +0 -0
  51. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/app.js +0 -0
  52. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/css/foundation.css +0 -0
  53. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/css/review.css +0 -0
  54. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/css/workspace.css +0 -0
  55. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/i18n.js +0 -0
  56. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/index.html +0 -0
  57. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/actions.js +0 -0
  58. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/api.js +0 -0
  59. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/diff.js +0 -0
  60. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/dom.js +0 -0
  61. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/editor-view.js +0 -0
  62. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/review-view.js +0 -0
  63. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/semantic.js +0 -0
  64. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/state.js +0 -0
  65. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/editor/js/tree-view.js +0 -0
  66. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/i18n/catalog/en.json +48 -2
  67. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/i18n/catalog/zh.json +48 -2
  68. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/i18n/texts/rules.en.md +2 -2
  69. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/i18n/texts/rules.zh.md +2 -2
  70. guarantee_based_coding-0.3.0/gbc/assets/i18n/texts/setup.en.md +110 -0
  71. guarantee_based_coding-0.3.0/gbc/assets/i18n/texts/setup.zh.md +89 -0
  72. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/skills/README.md +0 -0
  73. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/assets/skills/gbc-cli/SKILL.md +31 -11
  74. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/gbc/entry.py +9 -6
  75. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/guarantee_based_coding.egg-info/PKG-INFO +115 -108
  76. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/guarantee_based_coding.egg-info/SOURCES.txt +20 -1
  77. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/pyproject.toml +4 -1
  78. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/setup.cfg +4 -4
  79. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_assets.py +36 -0
  80. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_cli_commands.py +191 -19
  81. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_config_project.py +0 -0
  82. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_core_executor.py +0 -0
  83. guarantee_based_coding-0.3.0/tests/test_documentation.py +141 -0
  84. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_env_actions.py +0 -0
  85. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_errors_i18n.py +0 -0
  86. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_executor_externalized.py +0 -0
  87. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_gbc_md.py +0 -0
  88. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_guarantee_crud.py +0 -0
  89. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_guarantee_deps.py +84 -1
  90. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_guarantee_verify.py +0 -0
  91. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_i18n.py +0 -0
  92. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_intent_base.py +0 -0
  93. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_intent_editor_api.py +0 -0
  94. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_intent_flat.py +0 -0
  95. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_interface_base_crud.py +0 -0
  96. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_interface_base_deps.py +0 -0
  97. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_interface_base_query.py +0 -0
  98. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_interface_base_refactor.py +0 -0
  99. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_json_model_and_file_utils.py +0 -0
  100. guarantee_based_coding-0.3.0/tests/test_manual_packaging.py +49 -0
  101. guarantee_based_coding-0.3.0/tests/test_mcp_doc_tools.py +85 -0
  102. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/tests/test_safe_file_writer.py +0 -0
  103. guarantee_based_coding-0.3.0/tests/test_tree_interfaces.py +166 -0
  104. guarantee_based_coding-0.3.0/tests/test_tree_views.py +98 -0
  105. guarantee_based_coding-0.2.2/gbc/assets/i18n/texts/setup.en.md +0 -87
  106. guarantee_based_coding-0.2.2/gbc/assets/i18n/texts/setup.zh.md +0 -78
  107. guarantee_based_coding-0.2.2/tests/test_mcp_doc_tools.py +0 -49
  108. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/guarantee_based_coding.egg-info/dependency_links.txt +0 -0
  109. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/guarantee_based_coding.egg-info/entry_points.txt +0 -0
  110. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/guarantee_based_coding.egg-info/requires.txt +0 -0
  111. {guarantee_based_coding-0.2.2 → guarantee_based_coding-0.3.0}/guarantee_based_coding.egg-info/top_level.txt +0 -0
@@ -0,0 +1,3 @@
1
+ include build_support.py
2
+ include docs/en/quick-start.md docs/en/concepts.md docs/en/workflow.md docs/en/reference.md docs/en/onboarding-agent.md
3
+ include docs/zh/quick-start.md docs/zh/concepts.md docs/zh/workflow.md docs/zh/reference.md docs/zh/onboarding-agent.md
@@ -1,108 +1,115 @@
1
- Metadata-Version: 2.4
2
- Name: guarantee-based-coding
3
- Version: 0.2.2
4
- Summary: Make code safely modifiable even when not fully understood — turn implicit inter-module dependencies into explicit, executable, verifiable guarantees.
5
- Author: Jesse-x86
6
- License-Expression: Apache-2.0
7
- Project-URL: Homepage, https://github.com/Jesse-x86/guarantee-based-coding
8
- Project-URL: Repository, https://github.com/Jesse-x86/guarantee-based-coding
9
- Keywords: guarantee,testing,ai-coding,mcp,code-safety
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Topic :: Software Development :: Testing
14
- Requires-Python: >=3.10
15
- Description-Content-Type: text/markdown
16
- License-File: LICENSE
17
- Requires-Dist: typer[all]
18
- Requires-Dist: pydantic
19
- Requires-Dist: mcp<2.0,>=1.0
20
- Dynamic: license-file
21
-
22
- # Guarantee-Based Coding (GBC)
23
-
24
- **与其指望 AI 更聪明,不如让再笨的 agent 也改不坏你的代码。**
25
-
26
- **English version: [docs/en/README.md](docs/en/README.md)**
27
-
28
- GBC 把「这次改动会不会悄悄碰坏别处」从一种担心,变成可以当场验证的事实:你在意的行为被登记成
29
- 一条条带测试的**保证(guarantee)**,每次改完一跑——全绿就安心,有红就精确告诉你碰坏了谁、谁在
30
- 依赖它。
31
-
32
- ---
33
-
34
- ## 🚀 快速开始
35
-
36
- ```bash
37
- pipx install guarantee-based-coding
38
- gbc setup # 打印本地化接线指南:怎么把 MCP / skills 接入你的 agent
39
- ```
40
-
41
- 装好后 `gbc` 命令即在 PATH 上。完整上手(安装 → 接入 agent → 冒烟验证)见
42
- **[docs/zh/quick-start.md](./docs/zh/quick-start.md)**。
43
-
44
- 想让 agent 替你接入?把 **[docs/zh/onboarding-agent.md](./docs/zh/onboarding-agent.md)** 交给它。
45
-
46
- ---
47
-
48
- > 🚧 **交互式 demo 施工中**:旧的演示套件已废弃,新的交互式演示正在筹备。目前请直接读文档上手。
49
-
50
- ---
51
-
52
- ## 📚 文档
53
-
54
- | 你想 | 看这里 |
55
- |------|--------|
56
- | 装好并跑起来 | [快速开始](./docs/zh/quick-start.md) |
57
- | 懂 GBC 在保护什么 | [核心概念](./docs/zh/concepts.md) |
58
- | 在 GBC 下安全改代码 | [工作流](./docs/zh/workflow.md) |
59
- | 查命令 / 工具 / executor | [参考手册](./docs/zh/reference.md) |
60
- | 你是 agent,被要求接入 GBC | [Agent 上手](./docs/zh/onboarding-agent.md) |
61
-
62
- English docs: [docs/en/](./docs/en/)。
63
-
64
- ---
65
-
66
- ## 核心想法
67
-
68
- 代码之间的依赖本质上是一组**保证**。模块 A 依赖模块 B,不是依赖它的实现细节,而是依赖它的某些
69
- 行为承诺——返回值的类型、格式、语义。把这些保证从隐含变成**显式、可执行、可验证**,正确性的判定
70
- 就从「AI 觉得自己改对了」变成「所有被依赖的保证仍通过」——一个可机械验证的布尔条件。
71
-
72
- ![无 GBC vs 有 GBC](docs/assets/workflow-comparison.svg)
73
-
74
- GBC **不是**另一个要挑战 Cursor / Aider 的 AI 编程助手,而是填补它们在大型项目里缺的一环:
75
- **机器可判定的变更边界**。它与那些 agent 配合——改前查依赖树,改后必须跑通所有相关保证;也区别
76
- 于 CI——CI 是事后的,GBC 是准入制的门禁,错误在落地前就被拦在 agent 的上下文里。
77
-
78
- 完整概念、架构图、与已有概念(Design by Contract / 测试)的区别,见
79
- [核心概念](./docs/zh/concepts.md)
80
-
81
- ---
82
-
83
- ## 当前状态
84
-
85
- GBC 目前是一个可用的 Python 分发包(`pipx install guarantee-based-coding`),自身用 GBC 管理自己的
86
- `.gbc/`(dogfooding):
87
-
88
- - ✅ 核心保证机制(具名 id、多对一、出生即绿、退休保护、反查)
89
- - ✅ 多语言 executor 配置
90
- - ✅ CLI + MCP 双接口(含意图文档 `gbc doc` 全进 MCP)
91
- - ✅ 意图文档子系统(`gbc doc` / web 编辑器)
92
- - 随包分发的接线指南(`gbc setup`)与 CLI-only agent 的 skill 包
93
- - ✅ 原子文件写入 + 备份
94
-
95
-
96
- **诚实的局限**:保护能力上限 = 测试质量(测试只走 happy path 就是虚假安全感);依赖需主动登记,
97
- 覆盖率随项目增长需持续投入;每次验证真实跑测试,有一定延迟。详见
98
- [核心概念 · 局限性](./docs/zh/concepts.md#局限性诚实地说)。
99
-
100
- ---
101
-
102
- ## 许可
103
-
104
- 本项目采用 [Apache-2.0](./LICENSE) 许可证。
105
-
106
- ## 联系
107
-
108
- 如果你对这个方向感兴趣,欢迎 star、issue 或者直接联系我。
1
+ Metadata-Version: 2.4
2
+ Name: guarantee-based-coding
3
+ Version: 0.3.0
4
+ Summary: Make code safely modifiable even when not fully understood — turn implicit inter-module dependencies into explicit, executable, verifiable guarantees.
5
+ Author: Jesse-x86
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Jesse-x86/guarantee-based-coding
8
+ Project-URL: Repository, https://github.com/Jesse-x86/guarantee-based-coding
9
+ Keywords: guarantee,testing,ai-coding,mcp,code-safety
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Testing
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: typer[all]
18
+ Requires-Dist: pydantic
19
+ Requires-Dist: mcp<2.0,>=1.0
20
+ Dynamic: license-file
21
+
22
+ # Guarantee-Based Coding (GBC)
23
+
24
+ **与其指望 AI 更聪明,不如让再笨的 agent 也改不坏你的代码。**
25
+
26
+ **English version: [docs/en/README.md](docs/en/README.md)**
27
+
28
+ GBC 把「这次改动会不会悄悄碰坏别处」从一种担心,变成可以当场验证的事实:你在意的行为被登记成
29
+ 一条条带测试的**保证(guarantee)**,每次改完一跑——全绿就安心,有红就精确告诉你碰坏了谁、谁在
30
+ 依赖它。
31
+
32
+ ---
33
+
34
+ ## 🚀 快速开始
35
+
36
+ ```bash
37
+ pipx install guarantee-based-coding
38
+ gbc setup # 打印本地化接线指南:怎么把 MCP / skills 接入你的 agent
39
+ ```
40
+
41
+ 装好后 `gbc` 命令即在 PATH 上。完整上手(安装 → 接入 agent → 冒烟验证)见
42
+ **[docs/zh/quick-start.md](./docs/zh/quick-start.md)**。
43
+
44
+ 想让 agent 替你接入?把 **[docs/zh/onboarding-agent.md](./docs/zh/onboarding-agent.md)** 交给它。
45
+
46
+ ---
47
+
48
+ > 🚧 **交互式 demo 施工中**:旧的演示套件已废弃,新的交互式演示正在筹备。目前请直接读文档上手。
49
+
50
+ ---
51
+
52
+ ## 📚 文档
53
+
54
+ | 你想 | 看这里 |
55
+ |------|--------|
56
+ | 装好并跑起来 | [快速开始](./docs/zh/quick-start.md) |
57
+ | 懂 GBC 在保护什么 | [核心概念](./docs/zh/concepts.md) |
58
+ | 在 GBC 下安全改代码 | [工作流](./docs/zh/workflow.md) |
59
+ | 查命令 / 工具 / executor | [参考手册](./docs/zh/reference.md) |
60
+ | 你是 agent,被要求接入 GBC | [Agent 上手](./docs/zh/onboarding-agent.md) |
61
+
62
+ English docs: [docs/en/](./docs/en/)。
63
+
64
+ 安装后也能离线查询同版本手册:`gbc doc list --lang zh`、`gbc doc read quick-start --lang zh`、
65
+ `gbc doc search "保证" --lang zh`。`--help` 仍用于查简短命令语法。
66
+
67
+ 当前仓库包含 **0.3.0 开发中的改动,尚未发布**;0.2.3 已发布。
68
+ 0.3.0 中项目架构意图入口由 `gbc doc` 改为 `gbc intent`,MCP 的八个意图工具由 `doc_*`
69
+ 改为 `intent_*`,不保留旧别名。此后的 `gbc doc` 专门查询 GBC 手册。
70
+
71
+ ---
72
+
73
+ ## 核心想法
74
+
75
+ 代码之间的依赖本质上是一组**保证**。模块 A 依赖模块 B,不是依赖它的实现细节,而是依赖它的某些
76
+ 行为承诺——返回值的类型、格式、语义。把这些保证从隐含变成**显式、可执行、可验证**,正确性的判定
77
+ 就从「AI 觉得自己改对了」变成「所有被依赖的保证仍通过」——一个可机械验证的布尔条件。
78
+
79
+ ![无 GBC vs 有 GBC](docs/assets/workflow-comparison.svg)
80
+
81
+ GBC **不是**另一个要挑战 Cursor / Aider 的 AI 编程助手,而是填补它们在大型项目里缺的一环:
82
+ **机器可判定的变更边界**。它与那些 agent 配合——改前查依赖树,改后必须跑通所有相关保证;也区别
83
+ CI——CI 是事后的,GBC 是准入制的门禁,错误在落地前就被拦在 agent 的上下文里。
84
+
85
+ 完整概念、架构图、与已有概念(Design by Contract / 测试)的区别,见
86
+ [核心概念](./docs/zh/concepts.md)。
87
+
88
+ ---
89
+
90
+ ## 当前状态
91
+
92
+ GBC 目前是一个可用的 Python 分发包(`pipx install guarantee-based-coding`),自身用 GBC 管理自己的
93
+ `.gbc/`(dogfooding):
94
+
95
+ - ✅ 核心保证机制(具名 id、多对一、出生即绿、退休保护、反查)
96
+ - 多语言 executor 配置
97
+ - ✅ CLI + MCP 双接口(含意图文档 `gbc intent` 全进 MCP)
98
+ - 意图文档子系统(`gbc intent` / web 编辑器)
99
+ - ✅ 随包分发的接线指南(`gbc setup`)与 CLI-only agent 的 skill 包
100
+ - ✅ 原子文件写入 + 备份
101
+
102
+
103
+ **诚实的局限**:保护能力上限 = 测试质量(测试只走 happy path 就是虚假安全感);依赖需主动登记,
104
+ 覆盖率随项目增长需持续投入;每次验证真实跑测试,有一定延迟。详见
105
+ [核心概念 · 局限性](./docs/zh/concepts.md#局限性诚实地说)。
106
+
107
+ ---
108
+
109
+ ## 许可
110
+
111
+ 本项目采用 [Apache-2.0](./LICENSE) 许可证。
112
+
113
+ ## 联系
114
+
115
+ 如果你对这个方向感兴趣,欢迎 star、issue 或者直接联系我。
@@ -40,6 +40,13 @@ gbc setup # 打印本地化接线指南:怎么把 MCP / skills 接入
40
40
 
41
41
  English docs: [docs/en/](./docs/en/)。
42
42
 
43
+ 安装后也能离线查询同版本手册:`gbc doc list --lang zh`、`gbc doc read quick-start --lang zh`、
44
+ `gbc doc search "保证" --lang zh`。`--help` 仍用于查简短命令语法。
45
+
46
+ 当前仓库包含 **0.3.0 开发中的改动,尚未发布**;0.2.3 已发布。
47
+ 0.3.0 中项目架构意图入口由 `gbc doc` 改为 `gbc intent`,MCP 的八个意图工具由 `doc_*`
48
+ 改为 `intent_*`,不保留旧别名。此后的 `gbc doc` 专门查询 GBC 手册。
49
+
43
50
  ---
44
51
 
45
52
  ## 核心想法
@@ -66,8 +73,8 @@ GBC 目前是一个可用的 Python 分发包(`pipx install guarantee-based-co
66
73
 
67
74
  - ✅ 核心保证机制(具名 id、多对一、出生即绿、退休保护、反查)
68
75
  - ✅ 多语言 executor 配置
69
- - ✅ CLI + MCP 双接口(含意图文档 `gbc doc` 全进 MCP)
70
- - ✅ 意图文档子系统(`gbc doc` / web 编辑器)
76
+ - ✅ CLI + MCP 双接口(含意图文档 `gbc intent` 全进 MCP)
77
+ - ✅ 意图文档子系统(`gbc intent` / web 编辑器)
71
78
  - ✅ 随包分发的接线指南(`gbc setup`)与 CLI-only agent 的 skill 包
72
79
  - ✅ 原子文件写入 + 备份
73
80
 
@@ -0,0 +1,29 @@
1
+ """Copy the canonical offline manual into built packages, never the source tree."""
2
+ from pathlib import Path
3
+
4
+ from setuptools.command.build_py import build_py
5
+
6
+
7
+ MANUAL_LANGUAGES = ("en", "zh")
8
+ MANUAL_TOPICS = ("quick-start", "concepts", "workflow", "reference", "onboarding-agent")
9
+
10
+
11
+ class BuildPy(build_py):
12
+ """Include the fixed manual topics when building directly or from an sdist."""
13
+
14
+ def _manual_files(self):
15
+ root = Path(__file__).resolve().parent
16
+ for language in MANUAL_LANGUAGES:
17
+ for topic in MANUAL_TOPICS:
18
+ relative = Path(language) / f"{topic}.md"
19
+ yield root / "docs" / relative, Path(self.build_lib) / "gbc/assets/docs" / relative
20
+
21
+ def run(self):
22
+ super().run()
23
+ for source, destination in self._manual_files():
24
+ self.mkpath(str(destination.parent))
25
+ self.copy_file(str(source), str(destination))
26
+
27
+ def get_outputs(self, include_bytecode=True):
28
+ outputs = super().get_outputs(include_bytecode=include_bytecode)
29
+ return outputs + [str(destination) for _, destination in self._manual_files()]
@@ -0,0 +1,225 @@
1
+ # Core Concepts
2
+
3
+ > Language: [简体中文](../zh/concepts.md) | **English**
4
+
5
+ This page explains GBC's core concepts — what it actually protects, and how. To get hands-on first
6
+ see [quick-start.md](./quick-start.md); for the workflow see [workflow.md](./workflow.md).
7
+
8
+ ---
9
+
10
+ ## The problem: when changing code, how do you know what must not break?
11
+
12
+ A coding agent's core failure mode isn't writing wrong code — that can be retried. The real problem
13
+ is **silently breaking the implicit assumptions of existing code**. When an agent changes a
14
+ function's return format, other modules that depend on that format can quietly break — with no
15
+ mechanism telling the agent those dependencies exist, and none stopping it when the break happens.
16
+
17
+ ## The core idea: turn implicit dependencies into explicit guarantees
18
+
19
+ Dependencies between code are essentially a set of **guarantees**. Module A depends on module B not
20
+ on B's implementation details, but on some of B's behavioral promises — the type, format, semantics
21
+ of return values.
22
+
23
+ Make those guarantees **explicit, executable, and verifiable** and you get:
24
+
25
+ - Every change mechanically verifies whether all guarantees still hold;
26
+ - When a guarantee breaks, you know exactly which one and who depends on it;
27
+ - **Correctness shifts from "the AI thinks it got it right" to "every depended-on guarantee still
28
+ passes"** — a mechanically verifiable boolean.
29
+
30
+ ![Without GBC vs with GBC](../assets/workflow-comparison_en.svg)
31
+
32
+ ---
33
+
34
+ ## Architecture
35
+
36
+ ![GBC architecture](../assets/architecture_en.svg)
37
+
38
+ ### Three design principles
39
+
40
+ 1. **Zero source intrusion**: all metadata lives under the target project's `.gbc/` directory —
41
+ no source edits, no decorators/annotations.
42
+ 2. **Tests are user-owned**: GBC does not generate, store, or manage the test files themselves.
43
+ You organize tests your own way in your own project; GBC only **records which test backs which
44
+ guarantee, runs them, and aggregates results**.
45
+ 3. **Language-agnostic**: any language and test framework, via executor config.
46
+
47
+ ---
48
+
49
+ ## Two layers of contract
50
+
51
+ GBC pins down the impact of a change with two layers:
52
+
53
+ 1. **Intent layer**: in `.gbc/**/gbc.md`. Natural language (Markdown) defining a folder's role,
54
+ internal constraints, and architectural intent. It is the source of truth — it tells an agent
55
+ "what you should and shouldn't do here." **Human-held**; the agent only drafts.
56
+ 2. **Guarantee layer**: in `.gbc/**/*.json`. Executable, test-backed concrete behavioral promises.
57
+
58
+ When changing code, the agent must honor both the intent layer (don't violate the original purpose)
59
+ and the guarantee layer (don't break concrete behavior).
60
+
61
+ How to write intent docs (the three sections: intent / internal constraints / files) is in
62
+ [workflow.md](./workflow.md#writing-intent-docs).
63
+
64
+ ---
65
+
66
+ ## The intent document system (gbc.md)
67
+
68
+ The behavior layer guards "behavior doesn't break"; the intent layer guards "direction doesn't
69
+ drift" — both are pre-change defenses, but of different natures: guarantees are mechanically
70
+ verifiable (born-green / verify), while intent relies on **human sign-off + tool consistency**.
71
+
72
+ ### What it is
73
+
74
+ Each folder's intent lives in `.gbc/<path>/gbc.md`, made of three sections that are really
75
+ **visibility scopes**:
76
+
77
+ | Section | Answers | Who needs to know |
78
+ |---|---|---|
79
+ | **Intent** | What this is and why it exists | Outside (public contract) |
80
+ | **Internal constraints** | What it must / must never do | Internal coordination (package-private) |
81
+ | **Files** | Subfolders + file list, one role line each | Only the file itself (private) |
82
+
83
+ When unsure whether something is "intent vs constraint", ask per sentence: "who needs to know
84
+ this?". It only records the **current state** (what it is now, what it must do now), not diffs
85
+ against the past — phase words, roadmaps, and migration narratives are drift bait.
86
+
87
+ ### How it is maintained
88
+
89
+ - **Hierarchy**: a subfolder's intent auto-projects into its parent's entry; parent/child
90
+ consistency is a **deterministic constraint** maintained by the `gbc intent` tools (`intent check`
91
+ reports DRIFT / ORPHAN, `intent sync` repairs).
92
+ - **The only compliant entry**: `gbc intent` (CLI / MCP intent tools). Never hand-edit — hand-editing
93
+ drifts the deterministic constraint, downgrading "verifiable truth" to "best-effort habit".
94
+ - **Spec-first**: draft the intent, get human sign-off, commit it, then implement against the
95
+ written gbc.md.
96
+
97
+ ### How it relates to the guarantee layer
98
+
99
+ The intent layer answers "why, and what are the boundary obligations" — **not mechanically
100
+ verifiable**; it relies on human sign-off + intent check. The guarantee layer answers "does the
101
+ behavior still hold" — **mechanically verifiable**. The former prevents directional drift, the
102
+ latter prevents behavioral breakage; they complement each other.
103
+
104
+ ### How to treat it
105
+
106
+ It is a **snapshot of the current state, not a sacred text**: born to prevent drift, not to
107
+ freeze the architecture. Found it wrong, or it starts blocking reasonable evolution? Draft the
108
+ delta → human sign-off → commit through the tools — legitimate evolution, not a violation.
109
+ Piling responsibilities into one file instead of changing the intent (a god file) is exactly the
110
+ drift-guard mechanism turned upside down. For an agent: **read it (map before acting), obey it
111
+ (stay in scope), propose changes to it (through the official channel) — but don't own it.**
112
+
113
+ ---
114
+
115
+ ## Core terms
116
+
117
+ - **Provider**: the source file that offers a guarantee (e.g. `src/llm_client/client.py`).
118
+ - **Consumer / Dependent**: a file depending on a guarantee (e.g. `src/conversation/manager.py`).
119
+ - **Guarantee**: a **named** behavioral promise (id shaped `<symbol>.<behavior>`, path-free),
120
+ backed by a test + a description. **Multiple consumers may share one guarantee.**
121
+ - **Executor**: config defining how to run tests (command template, working dir, env vars, ...).
122
+
123
+ ### Two tiers of dependency edge
124
+
125
+ - **Symbol dependency (free)**: depends only on a signature or a symbol existing; no test, no
126
+ reverse edge.
127
+ - **Named guarantee dependency**: depends on concrete behavior. Registered **both ways** via the
128
+ reverse-edge mechanism — the provider's `provides[id].dependents` ⇄ the consumer's
129
+ `depends_on[].guarantees`, kept in sync by the tooling.
130
+
131
+ > Default to free symbol dependencies; upgrade to a named guarantee **only** when you depend on
132
+ > concrete behavior (not just a signature), and upgrade lazily.
133
+
134
+ ---
135
+
136
+ ## The unbreakable core invariants
137
+
138
+ Whichever surface you swap in — CLI / MCP / a future GUI — these engine-level invariants hold:
139
+
140
+ - **Guarantees are first-class; identity is a named id** (e.g. `get_config.never_none`, ≠ a test
141
+ path).
142
+ - **Many-to-one**: one guarantee can be shared by many consumers; hitting an existing one appends
143
+ a dependent and reuses it, rather than writing a second test.
144
+ - **Two-section self-contained meta**: one `.gbc` json per code file, `provides` (as provider) +
145
+ `depends_on` (as consumer).
146
+ - **Born-green**: on create / test change the test runs on the spot, and registration is refused
147
+ if it fails — the one integrity invariant, with no backdoor.
148
+ - **Retirement protection**: a guarantee with dependents refuses deletion.
149
+ - **Binary gate**: a test that ran is pass or fail; one that was skipped (heavy) is reported loudly
150
+ but never turns the gate red. Green = no failures.
151
+ - **heavy** is a cost rank (int) + an auto-run authorization: batch runs only heavy ≤ threshold;
152
+ a named verify ignores it.
153
+
154
+ ### What a meta file looks like
155
+
156
+ `client.py` (provider), at `.gbc/src/llm_client/gbc.client.py.json`:
157
+
158
+ ```json
159
+ {
160
+ "provides": {
161
+ "chat.content_is_str": {
162
+ "desc": "chat()'s result['content'] is a str; manager concatenates it into history directly",
163
+ "test": "tests/test_client_content_is_str.py::test_content_is_str",
164
+ "executor": "pytest-myproject",
165
+ "heavy": 0,
166
+ "dependents": ["src/conversation/manager.py"]
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ `manager.py` (consumer), at `.gbc/src/conversation/gbc.manager.py.json`, records the reverse edge:
173
+
174
+ ```json
175
+ {
176
+ "depends_on": [
177
+ {
178
+ "symbol": "src/llm_client/client.py:chat",
179
+ "guarantees": ["chat.content_is_str"]
180
+ }
181
+ ]
182
+ }
183
+ ```
184
+
185
+ Both directions are written by the tools (CLI / MCP); you don't hand-edit them.
186
+
187
+ ---
188
+
189
+ ## What it is not
190
+
191
+ GBC is **not** another AI coding assistant challenging Cursor or Aider. It fills the piece they lack
192
+ in large, complex projects: a **machine-verifiable boundary for change**.
193
+
194
+ - **Works with Cursor / Aider**: they're good at finding and editing code, but lack explicit
195
+ awareness of cross-module dependencies and thus break things silently. GBC gives them a
196
+ "constraint guardrail" — check the dependency tree before, and pass all relevant guarantees
197
+ after.
198
+ - **Different from CI**: CI is after-the-fact — it catches errors after commit. GBC is
199
+ admission-based — a gate inside the agent's workflow, catching errors before they land, inside
200
+ the agent's context.
201
+
202
+ ### How it differs from existing ideas
203
+
204
+ **"Isn't this just Design by Contract?"** Traditional contract programming has a module declare its
205
+ **own** contract. GBC's key differences: a guarantee is **registered by the dependent** ("what
206
+ behavior of yours I rely on" comes from the user), it **carries attribution** (who registered it
207
+ and why, so breaking it pinpoints impact), and it **targets AI agents** (a boundary for change,
208
+ not a runtime check).
209
+
210
+ **"Isn't this just testing?"** Technically a guarantee is a test file. Conceptually: it **carries
211
+ attribution** (records who registered it, which cross-module dependency it protects), it's a
212
+ **live gate** (not run after-the-fact in CI, but an admission condition when the agent changes
213
+ code), and it's **user-managed** (GBC manages the metadata and running, not the test files
214
+ themselves).
215
+
216
+ ---
217
+
218
+ ## Limitations (stated honestly)
219
+
220
+ - **Protection ceiling = test quality**: GBC only catches what a test can catch. Tests that only
221
+ walk the happy path make guarantees a false sense of safety. (Happy-path-only tests are the
222
+ textbook example.)
223
+ - **Manual registration cost**: dependencies must be registered by an agent or human. The per-edge
224
+ cost is small, but coverage takes ongoing investment as the project grows.
225
+ - **Run performance**: every verification really runs tests, so there's some latency cost.
@@ -0,0 +1,114 @@
1
+ # Onboarding Instructions for Agents
2
+
3
+ > Language: [简体中文](../zh/onboarding-agent.md) | **English**
4
+
5
+ Hi. If you're reading this, you're working inside a project and your human wants to use GBC — glad
6
+ you're here to wire it up. It's not much: confirm the tool is ready, wire it into the current
7
+ project, then work by the recommended workflow.
8
+
9
+ Two roles throughout:
10
+
11
+ - **The working project** — the project you're in right now; GBC gets wired in here.
12
+ - **The GBC tool** — a standalone tool already installed as the `gbc` command. You call it and
13
+ point it at the working project.
14
+
15
+ ---
16
+
17
+ ## ① Confirm the tool is ready
18
+
19
+ GBC ships as a standalone command-line tool. Confirm it's installed:
20
+
21
+ ```bash
22
+ gbc --help
23
+ ```
24
+
25
+ If not, have your human install it (or install it yourself when authorized):
26
+ `pipx install guarantee-based-coding`. Once installed, the `gbc` command is on PATH and the same
27
+ install is reused across projects.
28
+
29
+ > For a localized wiring guide (where the endpoints / skill files are), run `gbc setup` any time.
30
+
31
+ ---
32
+
33
+ ## ② Wire GBC into the current project
34
+
35
+ GBC's abilities reach you through two paths — use whichever you support (or both):
36
+
37
+ ### Path A — MCP (recommended)
38
+
39
+ Register GBC's MCP server for yourself, pointed at the working project. Start command:
40
+
41
+ ```
42
+ gbc mcp up <absolute path to the working project root>
43
+ ```
44
+
45
+ Register it however your framework adds MCP servers (for Claude Code, a `.mcp.json` in the project
46
+ root). Reconnect / restart afterward and the tools appear. MCP exposes the
47
+ guarantee engine + intent documents (`intent_*` tools), plus the offline manual
48
+ (`doc_list` / `doc_read` / `doc_search`). Read `gbc doc read onboarding-agent --lang en` when
49
+ you need this guide from an installed package; use `gbc intent` to manage project architecture.
50
+
51
+ ### Path B — Skills
52
+
53
+ Run `gbc setup`; it prints the absolute path to the bundled skill files. Copy them into wherever
54
+ your framework discovers skills (GBC materializes the files, you place them). The `gbc-cli` skill
55
+ teaches you to use every `gbc` command.
56
+
57
+ ### Once per project
58
+
59
+ GBC points at the working project, and the test executor follows that project's environment and
60
+ language — switch projects and it naturally needs reconfiguring. So re-run this wiring once per new
61
+ project (a few minutes).
62
+
63
+ ---
64
+
65
+ ## ③ Register an executor + smoke test
66
+
67
+ - Register a test executor (how to run tests): see [reference.md](./reference.md#executor-config).
68
+ Give it a **project-scoped name** (`pytest-<project>`), since executors are shared across
69
+ projects by name.
70
+ - Smoke test: run `gbc tree show` or `gbc doctor check` (over MCP, call `tree` / `check_consistency`).
71
+ If it returns, you're wired.
72
+
73
+ ---
74
+
75
+ ## ④ Before you touch code: don't let guarantees rot into fake safety
76
+
77
+ Wiring only connects the tools — it can't stop you from making them lie. A guarantee only protects
78
+ what it can actually catch, and a handful of moves quietly turn it into theater. These three are
79
+ worth carrying from day one, because they fail **silently** (full trap list in
80
+ [workflow.md](./workflow.md#a-few-traps-that-fail-silently)):
81
+
82
+ - **A guarantee test must be able to go red**: a fixture that only walks the happy path stays green
83
+ even after the behavior breaks = guarding nothing.
84
+ - **Promote the behavior you actually depend on**: non-null / non-empty / raises-on-X / ordering /
85
+ idempotence are behavior, not signature, and a free symbol dependency has no test guarding them.
86
+ - **When a guarantee goes red, restore it or announce it — never loosen the test**: relaxing /
87
+ retiring a test to turn green silently downgrades a real guarantee into fake safety.
88
+
89
+ Every time you register a dependency or a guarantee, ask: **"If the behavior I care about broke
90
+ right now, would a test actually go red?"** If no, fix that first.
91
+
92
+ ---
93
+
94
+ ## ⑤ Hierarchy and authority: stay within your scope
95
+
96
+ - **Top-level agent (architect / lead)**: you lead the intent. Draft `gbc.md` changes through
97
+ `gbc intent` (MCP intent tools / CLI) — never hand-edit — bound each subtask, review the local
98
+ contracts it registers, and do the final integration check after subtasks return.
99
+ - **Subagent (task worker)**: a focused implementer. It reads `gbc.md` without changing intent,
100
+ maintains any interface artifact required by that language/project (a Python project may use
101
+ `.pyi`) with the code, and owns the local GBC contracts introduced by its implementation:
102
+ query/reuse guarantees, register actual dependencies, and when a needed
103
+ guarantee is missing, write a narrow test that can genuinely go red and create it. Then self-prove with `verify_provider` /
104
+ `verify_guarantee`. An unregistered behavioral dependency means the task is not done.
105
+ - **Guardrails**: if your framework supports hooks (e.g. Claude Code's `pre-tool-use`), block every
106
+ agent from hand-editing GBC-managed files, and block subagents from changing intent or performing
107
+ unauthorized cross-scope operations such as retiring/disabling guarantees or refactoring other
108
+ files. **Do not blanket-block dependency registration, guarantee creation, or verification for
109
+ subagents.** Enforcement comes from the framework, independent of MCP vs CLI.
110
+
111
+ ---
112
+
113
+ The full "working safely under GBC" is in [workflow.md](./workflow.md); a command / tool cheat sheet
114
+ is in [reference.md](./reference.md); core concepts are in [concepts.md](./concepts.md).