@gitkraken/compose-tools 0.1.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 (122) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +19 -0
  3. package/README.md +543 -0
  4. package/dist/ai/session.d.ts +12 -0
  5. package/dist/ai/session.js +1 -0
  6. package/dist/ai/types.d.ts +31 -0
  7. package/dist/ai/types.js +1 -0
  8. package/dist/cancellation.d.ts +20 -0
  9. package/dist/cancellation.js +1 -0
  10. package/dist/errors/ai.d.ts +10 -0
  11. package/dist/errors/ai.js +1 -0
  12. package/dist/errors/git.d.ts +12 -0
  13. package/dist/errors/git.js +1 -0
  14. package/dist/errors/task.d.ts +6 -0
  15. package/dist/errors/task.js +1 -0
  16. package/dist/errors/workflow.d.ts +13 -0
  17. package/dist/errors/workflow.js +1 -0
  18. package/dist/git/apply-branches.d.ts +28 -0
  19. package/dist/git/apply-branches.js +1 -0
  20. package/dist/git/apply-target.d.ts +39 -0
  21. package/dist/git/apply-target.js +1 -0
  22. package/dist/git/commit-chain.d.ts +87 -0
  23. package/dist/git/commit-chain.js +6 -0
  24. package/dist/git/diff-collector.d.ts +80 -0
  25. package/dist/git/diff-collector.js +8 -0
  26. package/dist/git/index.d.ts +7 -0
  27. package/dist/git/index.js +1 -0
  28. package/dist/git/port-dispatch.d.ts +34 -0
  29. package/dist/git/port-dispatch.js +3 -0
  30. package/dist/git/require-exec.d.ts +17 -0
  31. package/dist/git/require-exec.js +1 -0
  32. package/dist/git/safety.d.ts +22 -0
  33. package/dist/git/safety.js +1 -0
  34. package/dist/git/types.d.ts +43 -0
  35. package/dist/git/types.js +1 -0
  36. package/dist/git/utils/conventions.d.ts +33 -0
  37. package/dist/git/utils/conventions.js +10 -0
  38. package/dist/git/utils/crypto.d.ts +4 -0
  39. package/dist/git/utils/crypto.js +1 -0
  40. package/dist/git/utils/hunk-parser.d.ts +6 -0
  41. package/dist/git/utils/hunk-parser.js +7 -0
  42. package/dist/git/utils/patch-builder.d.ts +6 -0
  43. package/dist/git/utils/patch-builder.js +2 -0
  44. package/dist/git/utils/temp-index.d.ts +6 -0
  45. package/dist/git/utils/temp-index.js +1 -0
  46. package/dist/index.d.ts +28 -0
  47. package/dist/index.js +1 -0
  48. package/dist/ports/git.d.ts +199 -0
  49. package/dist/ports/git.js +1 -0
  50. package/dist/tasks/ai-loop.d.ts +99 -0
  51. package/dist/tasks/ai-loop.js +2 -0
  52. package/dist/tasks/analyze/analyze.d.ts +6 -0
  53. package/dist/tasks/analyze/analyze.js +1 -0
  54. package/dist/tasks/analyze/prompt.d.ts +16 -0
  55. package/dist/tasks/analyze/prompt.js +34 -0
  56. package/dist/tasks/analyze/schema.d.ts +38 -0
  57. package/dist/tasks/analyze/schema.js +1 -0
  58. package/dist/tasks/analyze/types.d.ts +69 -0
  59. package/dist/tasks/analyze/types.js +1 -0
  60. package/dist/tasks/analyze/validator.d.ts +7 -0
  61. package/dist/tasks/analyze/validator.js +13 -0
  62. package/dist/tasks/compose-group/compose-group.d.ts +15 -0
  63. package/dist/tasks/compose-group/compose-group.js +1 -0
  64. package/dist/tasks/compose-group/prompt.d.ts +26 -0
  65. package/dist/tasks/compose-group/prompt.js +162 -0
  66. package/dist/tasks/compose-group/types.d.ts +62 -0
  67. package/dist/tasks/compose-group/types.js +1 -0
  68. package/dist/tasks/group/group.d.ts +6 -0
  69. package/dist/tasks/group/group.js +1 -0
  70. package/dist/tasks/group/prompt.d.ts +15 -0
  71. package/dist/tasks/group/prompt.js +158 -0
  72. package/dist/tasks/group/schema.d.ts +19 -0
  73. package/dist/tasks/group/schema.js +1 -0
  74. package/dist/tasks/group/types.d.ts +61 -0
  75. package/dist/tasks/group/types.js +1 -0
  76. package/dist/tasks/group/validator.d.ts +7 -0
  77. package/dist/tasks/group/validator.js +53 -0
  78. package/dist/tasks/index.d.ts +15 -0
  79. package/dist/tasks/index.js +1 -0
  80. package/dist/tasks/order/order.d.ts +6 -0
  81. package/dist/tasks/order/order.js +1 -0
  82. package/dist/tasks/order/prompt.d.ts +13 -0
  83. package/dist/tasks/order/prompt.js +45 -0
  84. package/dist/tasks/order/schema.d.ts +12 -0
  85. package/dist/tasks/order/schema.js +1 -0
  86. package/dist/tasks/order/types.d.ts +36 -0
  87. package/dist/tasks/order/types.js +1 -0
  88. package/dist/tasks/order/validator.d.ts +11 -0
  89. package/dist/tasks/order/validator.js +12 -0
  90. package/dist/tasks/partition/partition.d.ts +6 -0
  91. package/dist/tasks/partition/partition.js +1 -0
  92. package/dist/tasks/partition/prompt.d.ts +16 -0
  93. package/dist/tasks/partition/prompt.js +61 -0
  94. package/dist/tasks/partition/schema.d.ts +14 -0
  95. package/dist/tasks/partition/schema.js +1 -0
  96. package/dist/tasks/partition/types.d.ts +53 -0
  97. package/dist/tasks/partition/types.js +1 -0
  98. package/dist/tasks/partition/validator.d.ts +7 -0
  99. package/dist/tasks/partition/validator.js +11 -0
  100. package/dist/tasks/quick-compose/prompt.d.ts +18 -0
  101. package/dist/tasks/quick-compose/prompt.js +47 -0
  102. package/dist/tasks/quick-compose/quick-compose.d.ts +6 -0
  103. package/dist/tasks/quick-compose/quick-compose.js +1 -0
  104. package/dist/tasks/quick-compose/schema.d.ts +27 -0
  105. package/dist/tasks/quick-compose/schema.js +1 -0
  106. package/dist/tasks/quick-compose/types.d.ts +63 -0
  107. package/dist/tasks/quick-compose/types.js +1 -0
  108. package/dist/tasks/quick-compose/validator.d.ts +7 -0
  109. package/dist/tasks/quick-compose/validator.js +25 -0
  110. package/dist/tasks/session.d.ts +22 -0
  111. package/dist/tasks/session.js +1 -0
  112. package/dist/tasks/types.d.ts +101 -0
  113. package/dist/tasks/types.js +3 -0
  114. package/dist/workflows/compose.d.ts +371 -0
  115. package/dist/workflows/compose.js +2 -0
  116. package/dist/workflows/split.d.ts +80 -0
  117. package/dist/workflows/split.js +3 -0
  118. package/dist/workflows/types.d.ts +63 -0
  119. package/dist/workflows/types.js +1 -0
  120. package/dist/workflows/undo.d.ts +56 -0
  121. package/dist/workflows/undo.js +1 -0
  122. package/package.json +37 -0
@@ -0,0 +1,56 @@
1
+ import { ComposeGitPort } from "../ports/git.js";
2
+ import { UndoId, UndoResult, UndoValidation } from "@gitkraken/shared-tools";
3
+
4
+ //#region src/workflows/undo.d.ts
5
+ interface UndoComposeInput {
6
+ git: ComposeGitPort;
7
+ /** The undo ID returned by `compose()` or `split()`. */
8
+ undoId: UndoId;
9
+ /**
10
+ * When true, downgrades `branch_has_new_commits` blockers to warnings and
11
+ * proceeds. The `dirty_workdir` blocker is never force-able.
12
+ */
13
+ force?: boolean;
14
+ /** Called before each undo step with a human-readable description. */
15
+ onProgress?: (step: string) => void;
16
+ /** Optional cancellation signal. Forwarded to every git operation. */
17
+ signal?: AbortSignal;
18
+ }
19
+ interface ValidateUndoComposeInput {
20
+ git: ComposeGitPort;
21
+ /** The undo ID to validate. */
22
+ undoId: UndoId;
23
+ /** Optional cancellation signal. Forwarded to every git operation. */
24
+ signal?: AbortSignal;
25
+ }
26
+ /**
27
+ * Validate whether undoing a compose/split operation can safely proceed.
28
+ *
29
+ * Returns blockers (hard stops) and warnings (notable conditions). Does not
30
+ * mutate the repository. Use this for dry-run checks before {@link undoCompose}.
31
+ */
32
+ declare function validateUndoCompose(input: ValidateUndoComposeInput): Promise<UndoValidation>;
33
+ /**
34
+ * Reverse a previous `compose()` or `split()` operation.
35
+ *
36
+ * Loads the undo manifest persisted during the original operation, validates
37
+ * that the undo can proceed safely, then surgically reverses only the git
38
+ * mutations that were recorded. Returns a structured {@link UndoResult}.
39
+ *
40
+ * Safety:
41
+ * - Refuses to proceed when the working directory has uncommitted changes.
42
+ * - Refuses when a branch created by the operation has been modified since
43
+ * (unless `force` is set).
44
+ * - Best-effort on working directory restoration from stash backup.
45
+ */
46
+ declare function undoCompose(input: UndoComposeInput): Promise<UndoResult>;
47
+ /**
48
+ * List all undo manifest IDs stored in this repository.
49
+ *
50
+ * Returns IDs for all workflows that used the shared undo infrastructure
51
+ * (compose, split, and any future packages). Each ID can be passed to
52
+ * {@link validateUndoCompose} or {@link undoCompose}.
53
+ */
54
+ declare function listUndoIds(git: ComposeGitPort, signal?: AbortSignal): Promise<UndoId[]>;
55
+ //#endregion
56
+ export { UndoComposeInput, ValidateUndoComposeInput, listUndoIds, undoCompose, validateUndoCompose };
@@ -0,0 +1 @@
1
+ import{requireExec as e}from"../git/require-exec.js";import{UndoStore as t,undoOperation as n,validateUndo as r}from"@gitkraken/shared-tools";async function i(t){return r({git:e(t.git,`undo validation`),manifestId:t.undoId,signal:t.signal})}async function a(t){return n({git:e(t.git,`undo execution`),manifestId:t.undoId,force:t.force,onProgress:t.onProgress,signal:t.signal})}async function o(n,r){return new t(e(n,`undo listing`)).list({signal:r})}export{o as listUndoIds,a as undoCompose,i as validateUndoCompose};
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@gitkraken/compose-tools",
3
+ "version": "0.1.0",
4
+ "description": "AI-powered organization of git changes into clean, atomic commits and branches.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "author": "Axosoft, LLC dba GitKraken",
7
+ "engines": {
8
+ "node": ">= 22"
9
+ },
10
+ "type": "module",
11
+ "sideEffects": false,
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "CHANGELOG.md"
21
+ ],
22
+ "dependencies": {
23
+ "zod": "^4.3.6",
24
+ "@gitkraken/shared-tools": "^0.1.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^22.0.0",
28
+ "typescript": "^6.0.2",
29
+ "vitest": "^4.1.1"
30
+ },
31
+ "scripts": {
32
+ "build": "tsdown --config-loader=unrun",
33
+ "build:dev": "tsdown --config tsdown.dev.config.ts --config-loader=unrun",
34
+ "typecheck": "tsc --noEmit",
35
+ "test": "vitest run"
36
+ }
37
+ }