@hifullmoon/aicommit 1.4.0

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 (57) hide show
  1. package/.aicommit.config.example.json +118 -0
  2. package/CHANGELOG.md +131 -0
  3. package/LICENSE +21 -0
  4. package/README.md +406 -0
  5. package/README.zh-CN.md +408 -0
  6. package/SECURITY.md +33 -0
  7. package/bin/aicommit.js +47 -0
  8. package/docs/distribution.md +104 -0
  9. package/docs/examples/aicommit-policy.yml +24 -0
  10. package/docs/examples/commit-msg +4 -0
  11. package/docs/examples/extension/aicommit-extension.json +9 -0
  12. package/docs/examples/extension/index.mjs +32 -0
  13. package/docs/extensions.md +93 -0
  14. package/docs/privacy.md +58 -0
  15. package/docs/provider-compatibility.md +37 -0
  16. package/docs/provider-presets.md +100 -0
  17. package/docs/team-policy.md +86 -0
  18. package/docs/troubleshooting.md +37 -0
  19. package/package.json +100 -0
  20. package/presets/provider-presets.json +60 -0
  21. package/schemas/aicommit-extension.schema.json +27 -0
  22. package/schemas/aicommit-output.schema.json +86 -0
  23. package/schemas/aicommit-provider-presets.schema.json +56 -0
  24. package/schemas/aicommit-split-checkpoint.schema.json +92 -0
  25. package/schemas/aicommit-split-plan.schema.json +108 -0
  26. package/schemas/aicommit-team-policy.schema.json +59 -0
  27. package/src/api.js +740 -0
  28. package/src/cli.js +558 -0
  29. package/src/completion.js +136 -0
  30. package/src/config-command.js +59 -0
  31. package/src/config.js +524 -0
  32. package/src/context.js +537 -0
  33. package/src/credentials.js +123 -0
  34. package/src/doctor.js +131 -0
  35. package/src/errors.js +96 -0
  36. package/src/extension-runner.mjs +36 -0
  37. package/src/extensions.js +426 -0
  38. package/src/generation-ui.js +53 -0
  39. package/src/git.js +458 -0
  40. package/src/main.js +768 -0
  41. package/src/metrics.js +375 -0
  42. package/src/output.js +87 -0
  43. package/src/policy-command.js +172 -0
  44. package/src/policy.js +421 -0
  45. package/src/preset-command.js +91 -0
  46. package/src/provider-presets.js +361 -0
  47. package/src/providers.js +306 -0
  48. package/src/setup.js +268 -0
  49. package/src/split-checkpoint.js +252 -0
  50. package/src/split-hunks.js +263 -0
  51. package/src/split-plan.js +339 -0
  52. package/src/split.js +2285 -0
  53. package/src/team-policy.js +95 -0
  54. package/src/trust.js +31 -0
  55. package/src/ui.js +488 -0
  56. package/src/utils.js +165 -0
  57. package/templates/.aicommit.policy.json +22 -0
@@ -0,0 +1,118 @@
1
+ {
2
+ "defaultProvider": "minimax",
3
+ "providers": {
4
+ "minimax": {
5
+ "providerType": "minimax",
6
+ "apiUrl": "https://api.minimaxi.com/v1/chat/completions",
7
+ "apiKeyEnv": "MINIMAX_API_KEY",
8
+ "modelId": "MiniMax-M3",
9
+ "extraBody": {
10
+ "thinking": {
11
+ "type": "disabled"
12
+ },
13
+ "reasoning_split": true
14
+ }
15
+ },
16
+ "deepseek": {
17
+ "providerType": "deepseek",
18
+ "apiUrl": "https://api.deepseek.com/v1/chat/completions",
19
+ "apiKeyEnv": "DEEPSEEK_API_KEY",
20
+ "modelId": "deepseek-v4-flash"
21
+ },
22
+ "openrouter": {
23
+ "providerType": "openrouter",
24
+ "apiUrl": "https://openrouter.ai/api/v1/chat/completions",
25
+ "apiKeyEnv": "OPENROUTER_API_KEY",
26
+ "modelId": "openai/gpt-4o-mini"
27
+ },
28
+ "kimi-code": {
29
+ "providerType": "custom",
30
+ "apiUrl": "https://api.kimi.com/coding/v1/chat/completions",
31
+ "apiKeyEnv": "KIMI_API_KEY",
32
+ "modelId": "kimi-for-coding"
33
+ },
34
+ "ollama": {
35
+ "providerType": "ollama",
36
+ "apiUrl": "http://127.0.0.1:11434/api/chat",
37
+ "modelId": "qwen3:8b"
38
+ }
39
+ },
40
+ "language": "en",
41
+ "commitPolicy": {
42
+ "version": 1,
43
+ "types": ["feat", "fix", "chore", "docs", "refactor", "test", "style", "perf", "ci", "build"],
44
+ "scope": {
45
+ "mode": "optional",
46
+ "values": []
47
+ },
48
+ "subject": {
49
+ "maxLength": 72
50
+ },
51
+ "body": {
52
+ "mode": "optional",
53
+ "maxLines": 8
54
+ },
55
+ "breakingChange": "allow",
56
+ "language": "inherit"
57
+ },
58
+ "allowProjectPrompt": false,
59
+ "prompt": "",
60
+ "repositoryContext": {
61
+ "enabled": true,
62
+ "maxChars": 4000,
63
+ "recentCommits": {
64
+ "enabled": true,
65
+ "count": 12,
66
+ "maxChars": 1000
67
+ },
68
+ "packageBoundaries": {
69
+ "enabled": true,
70
+ "maxEntries": 40,
71
+ "maxChars": 800
72
+ },
73
+ "conventions": {
74
+ "enabled": true,
75
+ "trustedFiles": [],
76
+ "maxFiles": 4,
77
+ "maxChars": 1400
78
+ },
79
+ "commitlint": {
80
+ "enabled": true,
81
+ "maxChars": 800
82
+ }
83
+ },
84
+ "maxTokens": 1024,
85
+ "timeoutMs": 120000,
86
+ "retry": {
87
+ "maxAttempts": 3,
88
+ "baseDelayMs": 500,
89
+ "maxDelayMs": 5000
90
+ },
91
+ "credentialHelper": {
92
+ "enabled": false,
93
+ "username": "aicommit"
94
+ },
95
+ "metrics": {
96
+ "enabled": true,
97
+ "path": "",
98
+ "maxEntries": 500
99
+ },
100
+ "extensions": {
101
+ "manifests": [],
102
+ "timeoutMs": 3000,
103
+ "maxContextChars": 2000
104
+ },
105
+ "maxDiffChars": 30000,
106
+ "maxFileDiffChars": 3000,
107
+ "splitMaxDiffChars": 16000,
108
+ "splitMaxPlanFiles": 100,
109
+ "diffContextLines": 1,
110
+ "regenerateWithDiff": false,
111
+ "reasoning": {
112
+ "mode": "on",
113
+ "effort": "medium",
114
+ "maxTokens": 4096,
115
+ "maxDisplayChars": 12000
116
+ },
117
+ "stripFiles": ["*.min.js", "*.map", "*.snap"]
118
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,131 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow [Semantic Versioning](https://semver.org/).
4
+
5
+ ## [Unreleased]
6
+
7
+ ### Added
8
+
9
+ - Bundled Kimi Code setup preset and a copy-ready environment-variable configuration example using the OpenAI-compatible endpoint.
10
+
11
+ ### Changed
12
+
13
+ - Publish the CLI as the public npm organization package `@hifullmoon/aicommit`, with guarded bootstrap and Trusted Publishing release paths.
14
+ - Repository team policies now reject `-l`/`--lang` overrides, inherited policy languages are enforced during candidate validation, and split extension violations remain reviewable before commit.
15
+ - Provider preset compatibility now accepts valid core prerelease/build versions and compares prereleases using SemVer precedence.
16
+ - New committing split runs now detect unfinished checkpoints before provider access, report actionable resume/abort commands, and `aicommit split --abort` safely discards stale recovery metadata without changing commits, the index, or the worktree.
17
+
18
+ ### Security
19
+
20
+ - Provider endpoint userinfo, credential-like query parameters, and fragments are redacted from config inspection, diagnostics, debug output, extension inputs, and credential-helper failures.
21
+ - Extension provider adapters reject a broader set of credential-like request/configuration fields and fail closed when nested input exceeds the inspection depth.
22
+
23
+ ## [1.4.0] - 2026-08-24
24
+
25
+ ### Added
26
+
27
+ - Credential-free `aicommit config show|validate|path` inspection and generated Bash, Zsh, and Fish completion.
28
+ - Strict repository-owned team policy template plus deterministic local/CI `policy check` commands and bilingual migration examples.
29
+ - Independently updateable, versioned provider preset manifests with core/adapter compatibility declarations, atomic install, repair, and rollback.
30
+ - Credential-denied extension API v1 with isolated context-provider, message-validator, and provider-adapter interfaces, a strict manifest schema, and bilingual executable documentation.
31
+ - Signed GitHub release assets with SHA-256 checksums, SPDX SBOM, GitHub OIDC/Sigstore attestations, npm Trusted Publishing provenance, and a generated Homebrew formula.
32
+ - Automated npm/Homebrew installation smoke paths plus bilingual distribution, troubleshooting, privacy, and provider-compatibility guides.
33
+
34
+ ### Changed
35
+
36
+ - Interactive setup now consumes the active provider preset manifest instead of a hard-coded provider list.
37
+ - Provider request orchestration accepts asynchronous built-in or extension adapters without changing the Git and interaction flows.
38
+
39
+ ### Security
40
+
41
+ - Third-party extension code runs in a permissioned child process with a sanitized environment and no credential value; project config cannot enable extensions, v1 rejects credential permission requests, and Node.js 18 never falls back to unsandboxed execution.
42
+ - Team policy, config inspection, and preset management never resolve provider credentials; preset and extension manifests reject credential-bearing fields, unsafe paths, and incompatible contracts.
43
+
44
+ ## [1.3.0] - 2026-08-24
45
+
46
+ ### Added
47
+
48
+ - Explicit `--split=staged|all` scope selection plus versioned `aicommit split plan/apply` JSON artifacts with base-HEAD, change-set, and content-fingerprint validation.
49
+ - Code-free, owner-only split checkpoints and `aicommit split --resume`, including reconciliation of the post-commit/pre-checkpoint crash window.
50
+ - Strict split preflight checks for empty or duplicate groups, path coverage, rename/copy sides, conflicts, changed submodules, active hooks, and unborn branches.
51
+ - Opt-in `--split-hunks` support for tracked multi-hunk text modifications, with hunk IDs/ranges/hashes in plans and machine output.
52
+ - A shared end-to-end split fault matrix for SIGINT, process crashes, concurrent edits, hook failures, renames, deletions, binary files, and submodules.
53
+
54
+ ### Changed
55
+
56
+ - Every split group is now created from an immutable captured object snapshot through a temporary index; later worktree edits cannot silently enter pending commits.
57
+ - Hook and Git failures report checkpointed, in-flight, pending, and current worktree/index state without reordering or duplicating groups.
58
+ - Split apply and resume run without loading provider configuration or credentials.
59
+
60
+ ### Security
61
+
62
+ - Split plan and checkpoint readers reject unsafe paths, unknown fields, oversized artifacts, and symbolic links; artifacts never contain diffs, patch text, or file content.
63
+ - Experimental hunk execution validates selected patches entirely in temporary indexes and requires the final tree to reproduce every captured target blob exactly; otherwise planning falls back to file-level groups before the first commit.
64
+
65
+ ## [1.2.0] - 2026-08-24
66
+
67
+ ### Added
68
+
69
+ - Versioned `commitPolicy` rules for types, scopes, subject length, body, breaking changes, and language.
70
+ - Strictly bounded repository context from recent commit subjects, package boundaries, user-trusted convention files, and statically recognized commitlint rules.
71
+ - `aicommit stats` for local first-pass acceptance, edit/rewrite/failure rates, latency, token trends, and the 20% quality-improvement baseline; stats can be disabled or permanently cleared.
72
+ - Anonymous local eval coverage for single/mixed changes, renames, generated files, long diffs, Chinese/English output, and malformed weak-model candidates, enforced in CI at 99% or better.
73
+
74
+ ### Changed
75
+
76
+ - Replaced the default free-form prompt contract with an authoritative structured policy; user guidance is additive, and project-owned prompts now require the user-owned `allowProjectPrompt` opt-in.
77
+ - Commit generation now shows a bounded context summary before the provider request and allows every repository-context category to be disabled independently.
78
+ - Candidate responses are validated locally for policy compliance and diff/path alignment; hard policy failures receive at most one low-cost correction without re-sending the diff.
79
+ - Automatic policy corrections now contribute to the anonymous local rewrite metric.
80
+
81
+ ### Security
82
+
83
+ - Diff, file, path, history, and convention inputs now use explicit JSON envelopes marked as untrusted data, backed by a prompt-injection regression corpus.
84
+ - Project config can only disable repository context or lower user-owned ceilings; it cannot add trusted convention files, re-enable sources, expand budgets, or alter endpoints and credentials.
85
+ - Trusted convention reads reject paths outside the repository, symbolic links, and non-regular files; commitlint configuration is parsed as data and never executed.
86
+
87
+ ## [1.1.0] - 2026-08-24
88
+
89
+ ### Added
90
+
91
+ - Linux, macOS, and Windows CI across Node.js 18, 20, 22, and 24.
92
+ - ESLint, Prettier, c8 reporting, and a 70% minimum line-coverage gate.
93
+ - Setup and terminal UI smoke coverage plus installed-tarball dry-run tests.
94
+ - Release, security, contribution, privacy, and recovery documentation.
95
+ - Unified provider generation adapters and contract fixtures for OpenAI, OpenRouter, DeepSeek, MiniMax, Ollama, and custom endpoints.
96
+ - Bounded retries for rate limits, recoverable server failures, and interrupted network responses, including `Retry-After` support.
97
+ - Stable error categories and process exit codes for config, Git state, network, provider, response-format, sensitive-data, and concurrent-modification failures.
98
+ - `--output=text|json` with a published JSON schema and decoration-free stdout for automation.
99
+ - `aicommit doctor` diagnostics for runtime, configuration, endpoint security, provider capabilities, credentials, and connectivity.
100
+ - Optional Git credential-helper integration for OS-backed credential storage.
101
+ - Minimal local-only metrics with status, clear, enable, and disable commands.
102
+
103
+ ### Changed
104
+
105
+ - Constrained interactive prompt dependencies to releases that support Node.js 18.
106
+ - Normalized provider usage as input, output, and total tokens and exposed finish reasons through one internal response contract.
107
+ - Environment credentials now take priority over credential helpers and legacy plaintext configuration.
108
+ - Installed-package smoke tests now verify the machine interface and published schema.
109
+
110
+ ### Fixed
111
+
112
+ - Split planning scans complete untracked regular files for common sensitive content while keeping model previews bounded.
113
+ - Split planning no longer follows untracked symbolic links for previews or fingerprints.
114
+ - Non-interactive split mode fails closed before auto-staging detected sensitive files.
115
+ - Split-plan messages are sanitized before terminal display and commit execution.
116
+
117
+ ## [1.0.0] - 2026-08-24
118
+
119
+ ### Added
120
+
121
+ - Conventional commit generation in Chinese or English through OpenAI-compatible providers.
122
+ - Interactive staging, editing, regeneration, dry-run, reasoning display, and connection checks.
123
+ - File-level split planning and execution with Git-state concurrency checks.
124
+ - Provider presets and user/project configuration trust boundaries.
125
+
126
+ [Unreleased]: https://github.com/hi-fullmoon/AICommit/compare/v1.4.0...HEAD
127
+ [1.4.0]: https://github.com/hi-fullmoon/AICommit/compare/v1.3.0...v1.4.0
128
+ [1.3.0]: https://github.com/hi-fullmoon/AICommit/compare/v1.2.0...v1.3.0
129
+ [1.2.0]: https://github.com/hi-fullmoon/AICommit/compare/v1.1.0...v1.2.0
130
+ [1.1.0]: https://github.com/hi-fullmoon/AICommit/compare/v1.0.0...v1.1.0
131
+ [1.0.0]: https://github.com/hi-fullmoon/AICommit/releases/tag/v1.0.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zhengbiwen
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.