@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,27 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/hi-fullmoon/AICommit/schemas/aicommit-extension.schema.json",
4
+ "title": "AICommit extension manifest v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["kind", "apiVersion", "id", "version", "entry", "capabilities", "permissions"],
8
+ "properties": {
9
+ "kind": { "const": "aicommit-extension" },
10
+ "apiVersion": { "const": 1 },
11
+ "id": { "type": "string", "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$" },
12
+ "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$" },
13
+ "entry": { "type": "string", "pattern": "^[^/].*\\.mjs$" },
14
+ "capabilities": {
15
+ "type": "array",
16
+ "minItems": 1,
17
+ "uniqueItems": true,
18
+ "items": { "enum": ["contextProvider", "messageValidator", "providerAdapter"] }
19
+ },
20
+ "permissions": {
21
+ "type": "object",
22
+ "additionalProperties": false,
23
+ "required": ["credentials"],
24
+ "properties": { "credentials": { "const": false } }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,86 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/hi-fullmoon/AICommit/schemas/aicommit-output.schema.json",
4
+ "title": "aicommit machine output",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion",
9
+ "ok",
10
+ "message",
11
+ "plan",
12
+ "provider",
13
+ "model",
14
+ "latencyMs",
15
+ "usage",
16
+ "warnings",
17
+ "exitReason",
18
+ "committed",
19
+ "error"
20
+ ],
21
+ "properties": {
22
+ "schemaVersion": { "const": "1.0" },
23
+ "ok": { "type": "boolean" },
24
+ "message": { "type": ["string", "null"] },
25
+ "plan": {
26
+ "type": ["array", "null"],
27
+ "items": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "required": ["message", "files"],
31
+ "properties": {
32
+ "message": { "type": "string" },
33
+ "files": { "type": "array", "items": { "type": "string" } },
34
+ "hunks": {
35
+ "type": "array",
36
+ "items": {
37
+ "type": "object",
38
+ "additionalProperties": false,
39
+ "required": ["path", "ids"],
40
+ "properties": {
41
+ "path": { "type": "string" },
42
+ "ids": { "type": "array", "items": { "type": "string" } }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ },
49
+ "provider": { "type": ["string", "null"] },
50
+ "model": { "type": ["string", "null"] },
51
+ "latencyMs": { "type": ["number", "null"], "minimum": 0 },
52
+ "usage": {
53
+ "type": ["object", "null"],
54
+ "additionalProperties": false,
55
+ "properties": {
56
+ "inputTokens": { "type": "number", "minimum": 0 },
57
+ "outputTokens": { "type": "number", "minimum": 0 },
58
+ "totalTokens": { "type": "number", "minimum": 0 }
59
+ }
60
+ },
61
+ "warnings": { "type": "array", "items": { "type": "string" } },
62
+ "exitReason": { "type": "string", "minLength": 1 },
63
+ "committed": { "type": "boolean" },
64
+ "error": {
65
+ "type": ["object", "null"],
66
+ "additionalProperties": false,
67
+ "required": ["category", "message"],
68
+ "properties": {
69
+ "category": {
70
+ "enum": [
71
+ "config",
72
+ "git_state",
73
+ "network",
74
+ "provider",
75
+ "response_format",
76
+ "sensitive_data",
77
+ "concurrent_modification",
78
+ "internal"
79
+ ]
80
+ },
81
+ "message": { "type": "string" }
82
+ }
83
+ },
84
+ "data": { "type": "object" }
85
+ }
86
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/hi-fullmoon/AICommit/schemas/aicommit-provider-presets.schema.json",
4
+ "title": "AICommit provider preset manifest",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["kind", "schemaVersion", "version", "compatibility", "providers"],
8
+ "properties": {
9
+ "kind": { "const": "aicommit-provider-presets" },
10
+ "schemaVersion": { "const": 1 },
11
+ "version": {
12
+ "type": "string",
13
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
14
+ },
15
+ "compatibility": {
16
+ "type": "object",
17
+ "additionalProperties": false,
18
+ "required": ["coreMinimum", "coreMaximumExclusive", "adapterContract"],
19
+ "properties": {
20
+ "coreMinimum": {
21
+ "type": "string",
22
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
23
+ },
24
+ "coreMaximumExclusive": {
25
+ "type": "string",
26
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
27
+ },
28
+ "adapterContract": { "const": 1 }
29
+ }
30
+ },
31
+ "providers": {
32
+ "type": "array",
33
+ "minItems": 1,
34
+ "maxItems": 100,
35
+ "items": {
36
+ "type": "object",
37
+ "additionalProperties": false,
38
+ "required": ["id", "label", "adapter", "apiUrl", "modelId"],
39
+ "properties": {
40
+ "id": {
41
+ "type": "string",
42
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
43
+ "not": { "pattern": "^[Cc][Uu][Ss][Tt][Oo][Mm]$" }
44
+ },
45
+ "label": { "type": "string", "minLength": 1, "maxLength": 80 },
46
+ "adapter": {
47
+ "enum": ["openai", "openrouter", "deepseek", "minimax", "ollama", "custom"]
48
+ },
49
+ "apiUrl": { "type": "string", "minLength": 1, "maxLength": 2048 },
50
+ "modelId": { "type": "string", "minLength": 1, "maxLength": 256 },
51
+ "extraBody": { "type": "object" }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,92 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/hi-fullmoon/AICommit/schemas/aicommit-split-checkpoint.schema.json",
4
+ "title": "aicommit split checkpoint",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "kind",
9
+ "version",
10
+ "transactionId",
11
+ "createdAt",
12
+ "updatedAt",
13
+ "plan",
14
+ "snapshots",
15
+ "completed",
16
+ "inFlight"
17
+ ],
18
+ "properties": {
19
+ "kind": { "const": "aicommit-split-checkpoint" },
20
+ "version": { "const": 1 },
21
+ "transactionId": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
22
+ "createdAt": { "type": "string", "format": "date-time" },
23
+ "updatedAt": { "type": "string", "format": "date-time" },
24
+ "plan": { "$ref": "./aicommit-split-plan.schema.json" },
25
+ "snapshots": {
26
+ "type": "array",
27
+ "items": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "required": ["path", "target", "index"],
31
+ "properties": {
32
+ "path": { "type": "string", "minLength": 1, "maxLength": 1000 },
33
+ "target": { "$ref": "#/$defs/indexEntry" },
34
+ "index": { "$ref": "#/$defs/indexEntry" }
35
+ }
36
+ }
37
+ },
38
+ "completed": {
39
+ "type": "array",
40
+ "items": {
41
+ "type": "object",
42
+ "additionalProperties": false,
43
+ "required": ["index", "commit", "parent", "tree"],
44
+ "properties": {
45
+ "index": { "type": "integer", "minimum": 0 },
46
+ "commit": { "$ref": "#/$defs/objectId" },
47
+ "parent": {
48
+ "anyOf": [{ "$ref": "#/$defs/objectId" }, { "type": "null" }]
49
+ },
50
+ "tree": { "$ref": "#/$defs/objectId" }
51
+ }
52
+ }
53
+ },
54
+ "inFlight": {
55
+ "anyOf": [
56
+ {
57
+ "type": "object",
58
+ "additionalProperties": false,
59
+ "required": ["index", "parent", "tree"],
60
+ "properties": {
61
+ "index": { "type": "integer", "minimum": 0 },
62
+ "parent": {
63
+ "anyOf": [{ "$ref": "#/$defs/objectId" }, { "type": "null" }]
64
+ },
65
+ "tree": { "$ref": "#/$defs/objectId" }
66
+ }
67
+ },
68
+ { "type": "null" }
69
+ ]
70
+ }
71
+ },
72
+ "$defs": {
73
+ "objectId": {
74
+ "type": "string",
75
+ "pattern": "^(?:[0-9a-f]{40}|[0-9a-f]{64})$"
76
+ },
77
+ "indexEntry": {
78
+ "anyOf": [
79
+ {
80
+ "type": "object",
81
+ "additionalProperties": false,
82
+ "required": ["mode", "oid"],
83
+ "properties": {
84
+ "mode": { "type": "string", "pattern": "^[0-9]{6}$" },
85
+ "oid": { "$ref": "#/$defs/objectId" }
86
+ }
87
+ },
88
+ { "type": "null" }
89
+ ]
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,108 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/hi-fullmoon/AICommit/schemas/aicommit-split-plan.schema.json",
4
+ "title": "aicommit split plan",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "kind",
9
+ "version",
10
+ "createdAt",
11
+ "hunkMode",
12
+ "scope",
13
+ "baseHead",
14
+ "fingerprint",
15
+ "language",
16
+ "commitPolicy",
17
+ "changes",
18
+ "groups"
19
+ ],
20
+ "properties": {
21
+ "kind": { "const": "aicommit-split-plan" },
22
+ "version": { "const": 1 },
23
+ "createdAt": { "type": "string", "format": "date-time" },
24
+ "hunkMode": { "type": "boolean" },
25
+ "scope": { "enum": ["staged", "all"] },
26
+ "baseHead": {
27
+ "type": ["string", "null"],
28
+ "pattern": "^(?:[0-9a-f]{40}|[0-9a-f]{64})$"
29
+ },
30
+ "fingerprint": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
31
+ "language": { "enum": ["zh", "en"] },
32
+ "commitPolicy": { "type": "object" },
33
+ "changes": {
34
+ "type": "array",
35
+ "minItems": 1,
36
+ "maxItems": 10000,
37
+ "items": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "required": ["status", "path", "addPaths"],
41
+ "properties": {
42
+ "status": { "type": "string", "minLength": 1, "maxLength": 8 },
43
+ "path": { "type": "string", "minLength": 1, "maxLength": 1000 },
44
+ "addPaths": {
45
+ "type": "array",
46
+ "minItems": 1,
47
+ "maxItems": 2,
48
+ "items": { "type": "string", "minLength": 1, "maxLength": 1000 }
49
+ },
50
+ "hunks": {
51
+ "type": "array",
52
+ "minItems": 2,
53
+ "maxItems": 1000,
54
+ "items": { "$ref": "#/$defs/hunk" }
55
+ }
56
+ }
57
+ }
58
+ },
59
+ "groups": {
60
+ "type": "array",
61
+ "minItems": 1,
62
+ "maxItems": 1000,
63
+ "items": {
64
+ "type": "object",
65
+ "additionalProperties": false,
66
+ "required": ["message", "files"],
67
+ "properties": {
68
+ "message": { "type": "string", "minLength": 1, "maxLength": 10000 },
69
+ "files": {
70
+ "type": "array",
71
+ "items": { "type": "string", "minLength": 1, "maxLength": 1000 }
72
+ },
73
+ "hunks": {
74
+ "type": "array",
75
+ "items": {
76
+ "type": "object",
77
+ "additionalProperties": false,
78
+ "required": ["path", "ids"],
79
+ "properties": {
80
+ "path": { "type": "string", "minLength": 1, "maxLength": 1000 },
81
+ "ids": {
82
+ "type": "array",
83
+ "minItems": 1,
84
+ "items": { "type": "string", "pattern": "^H[1-9][0-9]*$" }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ },
93
+ "$defs": {
94
+ "hunk": {
95
+ "type": "object",
96
+ "additionalProperties": false,
97
+ "required": ["id", "hash", "oldStart", "oldLines", "newStart", "newLines"],
98
+ "properties": {
99
+ "id": { "type": "string", "pattern": "^H[1-9][0-9]*$" },
100
+ "hash": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
101
+ "oldStart": { "type": "integer", "minimum": 0 },
102
+ "oldLines": { "type": "integer", "minimum": 0 },
103
+ "newStart": { "type": "integer", "minimum": 0 },
104
+ "newLines": { "type": "integer", "minimum": 0 }
105
+ }
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/hi-fullmoon/AICommit/schemas/aicommit-team-policy.schema.json",
4
+ "title": "AICommit team policy",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["kind", "version", "language", "commitPolicy"],
8
+ "properties": {
9
+ "kind": { "const": "aicommit-team-policy" },
10
+ "version": { "const": 1 },
11
+ "language": { "enum": ["zh", "en"] },
12
+ "commitPolicy": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["version", "types", "scope", "subject", "body", "breakingChange", "language"],
16
+ "properties": {
17
+ "version": { "const": 1 },
18
+ "types": {
19
+ "type": "array",
20
+ "minItems": 1,
21
+ "maxItems": 32,
22
+ "uniqueItems": true,
23
+ "items": { "type": "string", "pattern": "^[a-z][a-z0-9-]{0,31}$" }
24
+ },
25
+ "scope": {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": ["mode", "values"],
29
+ "properties": {
30
+ "mode": { "enum": ["optional", "required", "forbidden"] },
31
+ "values": {
32
+ "type": "array",
33
+ "maxItems": 64,
34
+ "uniqueItems": true,
35
+ "items": { "type": "string", "minLength": 1, "maxLength": 64 }
36
+ }
37
+ }
38
+ },
39
+ "subject": {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "required": ["maxLength"],
43
+ "properties": { "maxLength": { "type": "integer", "minimum": 1, "maximum": 200 } }
44
+ },
45
+ "body": {
46
+ "type": "object",
47
+ "additionalProperties": false,
48
+ "required": ["mode", "maxLines"],
49
+ "properties": {
50
+ "mode": { "enum": ["optional", "required", "forbidden"] },
51
+ "maxLines": { "type": "integer", "minimum": 0, "maximum": 50 }
52
+ }
53
+ },
54
+ "breakingChange": { "enum": ["allow", "require", "forbid"] },
55
+ "language": { "enum": ["inherit", "zh", "en"] }
56
+ }
57
+ }
58
+ }
59
+ }