gitsage-ai 0.2.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.
- gitsage_ai-0.2.0/.env.example +14 -0
- gitsage_ai-0.2.0/.gitignore +37 -0
- gitsage_ai-0.2.0/.gitsage/skills/commit/SKILL.md +39 -0
- gitsage_ai-0.2.0/CHANGELOG.md +68 -0
- gitsage_ai-0.2.0/CTX.md +26 -0
- gitsage_ai-0.2.0/CTX.md.bak +19 -0
- gitsage_ai-0.2.0/LICENSE +21 -0
- gitsage_ai-0.2.0/PKG-INFO +485 -0
- gitsage_ai-0.2.0/README.md +424 -0
- gitsage_ai-0.2.0/docs/design.md +696 -0
- gitsage_ai-0.2.0/gitsage/__init__.py +4 -0
- gitsage_ai-0.2.0/gitsage/agent/__init__.py +22 -0
- gitsage_ai-0.2.0/gitsage/agent/catchup_agent.py +116 -0
- gitsage_ai-0.2.0/gitsage/agent/explain_agent.py +326 -0
- gitsage_ai-0.2.0/gitsage/agent/llm.py +250 -0
- gitsage_ai-0.2.0/gitsage/agent/models.py +89 -0
- gitsage_ai-0.2.0/gitsage/agent/prompts.py +371 -0
- gitsage_ai-0.2.0/gitsage/cli.py +1649 -0
- gitsage_ai-0.2.0/gitsage/config.py +206 -0
- gitsage_ai-0.2.0/gitsage/context/__init__.py +17 -0
- gitsage_ai-0.2.0/gitsage/context/blame.py +208 -0
- gitsage_ai-0.2.0/gitsage/context/builder.py +94 -0
- gitsage_ai-0.2.0/gitsage/context/ctx_reader.py +183 -0
- gitsage_ai-0.2.0/gitsage/context/git_reader.py +339 -0
- gitsage_ai-0.2.0/gitsage/context/memory.py +226 -0
- gitsage_ai-0.2.0/gitsage/github/__init__.py +0 -0
- gitsage_ai-0.2.0/gitsage/harness/__init__.py +4 -0
- gitsage_ai-0.2.0/gitsage/harness/hooks.py +52 -0
- gitsage_ai-0.2.0/gitsage/harness/override.py +53 -0
- gitsage_ai-0.2.0/gitsage/harness/quality_gate.py +50 -0
- gitsage_ai-0.2.0/gitsage/mcp/__init__.py +3 -0
- gitsage_ai-0.2.0/gitsage/mcp/server.py +311 -0
- gitsage_ai-0.2.0/gitsage/preferences.py +281 -0
- gitsage_ai-0.2.0/gitsage/renderer/__init__.py +2 -0
- gitsage_ai-0.2.0/gitsage/renderer/interactive.py +97 -0
- gitsage_ai-0.2.0/gitsage/skills/__init__.py +2 -0
- gitsage_ai-0.2.0/gitsage/skills/loader.py +73 -0
- gitsage_ai-0.2.0/gitsage/wizard.py +486 -0
- gitsage_ai-0.2.0/pyproject.toml +69 -0
- gitsage_ai-0.2.0/scratch.md +22 -0
- gitsage_ai-0.2.0/test.md +1 -0
- gitsage_ai-0.2.0/tests/__init__.py +0 -0
- gitsage_ai-0.2.0/tests/conftest.py +86 -0
- gitsage_ai-0.2.0/tests/test_agent.py +274 -0
- gitsage_ai-0.2.0/tests/test_catchup.py +147 -0
- gitsage_ai-0.2.0/tests/test_config.py +180 -0
- gitsage_ai-0.2.0/tests/test_context.py +481 -0
- gitsage_ai-0.2.0/tests/test_explain_agent.py +270 -0
- gitsage_ai-0.2.0/tests/test_harness.py +226 -0
- gitsage_ai-0.2.0/tests/test_mcp.py +319 -0
- gitsage_ai-0.2.0/tests/test_preferences.py +131 -0
- gitsage_ai-0.2.0/tests/test_wizard.py +244 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# LLM Provider API Keys (fill in the one you're using)
|
|
2
|
+
|
|
3
|
+
# DeepSeek (recommended — best value)
|
|
4
|
+
DEEPSEEK_API_KEY=sk-your_key_here
|
|
5
|
+
|
|
6
|
+
# Anthropic Claude (optional)
|
|
7
|
+
ANTHROPIC_API_KEY=sk-ant-your_key_here
|
|
8
|
+
|
|
9
|
+
# OpenAI (optional)
|
|
10
|
+
OPENAI_API_KEY=sk-your_key_here
|
|
11
|
+
|
|
12
|
+
# GitHub (optional — needed for gitsage explain/catchup to fetch PR/Issue context)
|
|
13
|
+
# Scopes needed: repo (private) or public_repo (public only)
|
|
14
|
+
GITHUB_TOKEN=ghp_your_token_here
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.so
|
|
5
|
+
.Python
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
*.egg-info/
|
|
9
|
+
.eggs/
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
env/
|
|
15
|
+
|
|
16
|
+
# Environment — NEVER commit
|
|
17
|
+
.env
|
|
18
|
+
.env.local
|
|
19
|
+
|
|
20
|
+
# IDE
|
|
21
|
+
.idea/
|
|
22
|
+
.vscode/
|
|
23
|
+
.DS_Store
|
|
24
|
+
|
|
25
|
+
# Testing
|
|
26
|
+
.pytest_cache/
|
|
27
|
+
.coverage
|
|
28
|
+
htmlcov/
|
|
29
|
+
.mypy_cache/
|
|
30
|
+
.ruff_cache/
|
|
31
|
+
|
|
32
|
+
# gitsage runtime
|
|
33
|
+
.gitsage_cache/
|
|
34
|
+
CTX.local.md
|
|
35
|
+
|
|
36
|
+
# Local memory (auto-generated)
|
|
37
|
+
~/.gitsage/memory/
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commit
|
|
3
|
+
description: Generate git commit messages following project conventions
|
|
4
|
+
trigger: auto
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Reasoning Steps
|
|
8
|
+
|
|
9
|
+
1. Analyze staged diff — identify the INTENT, not just what files changed
|
|
10
|
+
2. Cross-check against CTX.md commit conventions
|
|
11
|
+
3. Extract JIRA/ticket number from branch name (if pattern matches)
|
|
12
|
+
4. Generate primary candidate + 2 alternatives
|
|
13
|
+
5. Assign confidence and reasoning to each candidate
|
|
14
|
+
|
|
15
|
+
## Output Format
|
|
16
|
+
|
|
17
|
+
Return structured JSON:
|
|
18
|
+
{
|
|
19
|
+
"candidates": [
|
|
20
|
+
{
|
|
21
|
+
"message": "feat(payment): add retry mechanism with exponential backoff",
|
|
22
|
+
"confidence": "high",
|
|
23
|
+
"reason": "Clear intent from diff, matches project conventions"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"message": "feat: add payment retry logic",
|
|
27
|
+
"confidence": "medium",
|
|
28
|
+
"reason": "Missing module scope"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"warning": null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
## Guidelines
|
|
35
|
+
|
|
36
|
+
- Extract purpose from diff, don't list filenames
|
|
37
|
+
- If changes span multiple unrelated modules, suggest splitting
|
|
38
|
+
- Set confidence to "low" when diff intent is unclear
|
|
39
|
+
- warning field: use when commit should be split or something unusual detected
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to gitsage are documented here.
|
|
4
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## [0.2.0] — 2026-06-24
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
**MCP generation tools**
|
|
13
|
+
- `generate_commit_message` — AI-generates commit candidates for staged changes via MCP. Runs the complete gitsage commit pipeline (CTX.md rules, memory, quality gate, deterministic override, style preferences) and returns ranked candidates with confidence scores and reasons. Any MCP-compatible client (Claude Code, Cursor, etc.) can now trigger gitsage generation directly.
|
|
14
|
+
- `generate_standup` — AI-generates a standup report from today's commits via MCP. Respects CTX.md, memory and style preferences. Returns structured content with commit count and date.
|
|
15
|
+
|
|
16
|
+
**Skill management**
|
|
17
|
+
- `gitsage skill show <name>` — displays full SKILL.md content with Markdown syntax highlighting.
|
|
18
|
+
- `gitsage skill add [name]` — interactive wizard that creates a correctly-formed SKILL.md (frontmatter + structured body template) in project or global scope.
|
|
19
|
+
- `gitsage skill edit <name>` — opens a skill directly in `$EDITOR`.
|
|
20
|
+
|
|
21
|
+
**`config init` interactive review loop**
|
|
22
|
+
- After AI draft generation, users can apply natural-language modifications in a loop (e.g. "把站会格式改成英文", "加一条规则:禁止用英文") before saving. Modifications call a dedicated LLM pass and the updated content is shown immediately.
|
|
23
|
+
- Mixed-language repo detection now prompts for explicit language choice (zh/en) before generation.
|
|
24
|
+
- Multi-round pre-generation adjustment: each line adds an instruction; empty line proceeds to generate.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- `config init` review loop: `[y/回车]`, `[e]`, `[q]` shortcut labels were eaten by Rich's markup parser — escaped with `\[`.
|
|
29
|
+
- `config init` input prompts: Chinese text in `input()` prompt caused readline to miscount cursor width, making backspace leave residual characters. Replaced with `console.input()` throughout.
|
|
30
|
+
- CTX modify prompt / `StandupOutput` mismatch: system prompt said "output CTX.md only" while the code required JSON — the model returned empty content. Prompt updated to specify `{"content": "...", "items": []}` format.
|
|
31
|
+
- Language preamble injected at top of system prompt (not appended) for stronger model compliance.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- MCP server description updated to reflect new generation capabilities.
|
|
36
|
+
- Project URLs in `pyproject.toml` corrected to `Moyonx/gitsage`.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## [0.1.0] — 2026-06-23
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- **`gitsage commit`** — interactive commit message generation with 2–3 ranked candidates. Modes: `interactive` (default), `print`, `execute`, `hook` (for `prepare-commit-msg`). `--estimate` flag previews token cost.
|
|
45
|
+
- **`gitsage standup`** — standup report from today's commits. `--print` for pipe-friendly plain text output.
|
|
46
|
+
- **`gitsage pr`** — PR title and description for the current branch vs a base branch.
|
|
47
|
+
- **`gitsage explain <file>`** — code archaeology: traces why code exists using git blame, commit history, and optional GitHub PR/Issue enrichment. Iterative agent loop with tool calls.
|
|
48
|
+
- **`gitsage catchup`** — recent changes summary over a configurable time window.
|
|
49
|
+
- **`gitsage config init`** — analyses git history and AI-generates a `CTX.md` project context file.
|
|
50
|
+
- **`gitsage config show / set`** — view and modify configuration.
|
|
51
|
+
- **`gitsage setup`** — interactive LLM provider wizard (Anthropic, OpenAI, DeepSeek, Ollama).
|
|
52
|
+
- **`gitsage preferences`** — user preference survey: output language, emoji, scope, commit length, ticket format, standup audience.
|
|
53
|
+
- **`gitsage model list / set / test`** — model management and connection testing.
|
|
54
|
+
- **`gitsage memory show / clear`** — per-repo memory that summarises commit history and learned style.
|
|
55
|
+
- **`gitsage skill list`** — list available skills from project and global directories.
|
|
56
|
+
- **`gitsage install-hooks`** — installs `prepare-commit-msg` git hook for automatic suggestion on every `git commit`.
|
|
57
|
+
- **`gitsage install-completion`** — shell tab completion for bash/zsh/fish.
|
|
58
|
+
- **`gitsage doctor`** — environment and configuration health check.
|
|
59
|
+
- **MCP Server** (`gitsage mcp serve`) — exposes git state as MCP tools: `get_staged_diff`, `get_recent_commits`, `get_git_status`, `get_branch_info`, `get_file_history`.
|
|
60
|
+
- **`gitsage mcp install / status`** — register with Claude Desktop, Cursor, or any MCP client.
|
|
61
|
+
- **Harness layer** — `QualityGate` enforces commit message rules (length, language, verb-start); `DeterministicOverride` injects ticket numbers and strips forbidden content regardless of LLM output.
|
|
62
|
+
- **CTX.md** context system — project-level conventions file; parsed for commit rules, always/never rules, and language.
|
|
63
|
+
- **Memory system** — append-on-commit, LLM-summarised every 20 observations, per-repo Markdown file.
|
|
64
|
+
- **Skills system** — SKILL.md files in `.gitsage/skills/<name>/` inject domain-specific reasoning into prompts.
|
|
65
|
+
- **Graceful degradation** — rate limit handling, LLM unavailability fallback with diff summary, GitHub-token-less local mode for `explain`.
|
|
66
|
+
|
|
67
|
+
[0.2.0]: https://github.com/Moyonx/gitsage/compare/v0.1.0...v0.2.0
|
|
68
|
+
[0.1.0]: https://github.com/Moyonx/gitsage/releases/tag/v0.1.0
|
gitsage_ai-0.2.0/CTX.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# gitsage - 项目上下文
|
|
2
|
+
|
|
3
|
+
## 项目背景
|
|
4
|
+
(请在此描述项目目的与功能)
|
|
5
|
+
|
|
6
|
+
## 提交规范
|
|
7
|
+
- 使用 Conventional Commits 格式:`<type>(<scope>): <description>`
|
|
8
|
+
- 类型:feat / fix / refactor / chore / docs
|
|
9
|
+
- 作用域:cli / preferences / agent / explain / readme 等模块名
|
|
10
|
+
- 描述使用中文,简洁明确(平均 50 字符)
|
|
11
|
+
- 示例:`feat(cli): config init 预生成调整改为多轮输入`
|
|
12
|
+
|
|
13
|
+
## 站会报告格式
|
|
14
|
+
- 面向技术团队
|
|
15
|
+
- 按以下模板输出:
|
|
16
|
+
- 昨日完成:...
|
|
17
|
+
- 今日计划:...
|
|
18
|
+
- 阻塞问题:...
|
|
19
|
+
- 每项使用一句简要的中文描述
|
|
20
|
+
|
|
21
|
+
## 规则
|
|
22
|
+
- 始终:提交信息使用中文
|
|
23
|
+
- 始终:commit message 遵循 Conventional Commits
|
|
24
|
+
- 始终:添加合适的作用域(scope)
|
|
25
|
+
- 从不:在描述中使用表情符号
|
|
26
|
+
- 从不:提交信息超过 100 字符
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CTX.md — gitsage 项目自身的上下文配置
|
|
2
|
+
|
|
3
|
+
## 项目背景
|
|
4
|
+
gitsage 是一个 git-native AI 开发者工作流助手,Python 实现。
|
|
5
|
+
核心模块:cli / config / context / agent / harness / skills / mcp
|
|
6
|
+
|
|
7
|
+
## Commit 规范
|
|
8
|
+
格式:<类型>(<模块>): <描述>
|
|
9
|
+
类型:feat / fix / refactor / test / docs / chore
|
|
10
|
+
语言:英文
|
|
11
|
+
示例:feat(cli): add interactive commit selection mode
|
|
12
|
+
|
|
13
|
+
## 规则
|
|
14
|
+
always:
|
|
15
|
+
- commit message 使用英文
|
|
16
|
+
- 描述简洁,动词开头
|
|
17
|
+
never:
|
|
18
|
+
- 超过 72 字符
|
|
19
|
+
- 包含文件路径
|
gitsage_ai-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 gitsage Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|