@shirokuma-library/shirokuma-docs 0.3.0-alpha.19 → 0.3.0-alpha.20

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.

Potentially problematic release.


This version of @shirokuma-library/shirokuma-docs might be problematic. Click here for more details.

@@ -0,0 +1,60 @@
1
+ /**
2
+ * git commit-push - Stage, commit, and push in a single command
3
+ *
4
+ * Consolidates git add + commit + push into one operation for AI agents,
5
+ * reducing context window usage (3 commands → 1).
6
+ *
7
+ * Usage:
8
+ * shirokuma-docs git commit-push -m "fix: タイポを修正" --issue 1416
9
+ * shirokuma-docs git commit-push -m "fix: タイポを修正" -f src/index.ts -f src/utils.ts
10
+ */
11
+ import { Logger } from "../../utils/logger.js";
12
+ export interface CommitPushOptions {
13
+ message: string;
14
+ files?: string[];
15
+ issue?: number;
16
+ verbose?: boolean;
17
+ }
18
+ export interface CommitPushResult {
19
+ branch: string | null;
20
+ commit_hash: string;
21
+ commit_message: string;
22
+ files_staged: string[];
23
+ pushed: boolean;
24
+ error?: string;
25
+ }
26
+ /**
27
+ * Build commit message, optionally appending issue reference (#N).
28
+ * Skips appending if the reference already exists in the message.
29
+ *
30
+ * @param message - Base commit message
31
+ * @param issue - Issue number to append as (#N), or undefined to skip
32
+ * @returns Commit message with optional issue reference
33
+ */
34
+ export declare function buildCommitMessage(message: string, issue: number | undefined): string;
35
+ /**
36
+ * Assemble CommitPushResult from commit operation data.
37
+ * Pure function - no I/O, fully testable.
38
+ *
39
+ * @param args - Commit operation data fields
40
+ * @returns Structured result for JSON output
41
+ */
42
+ export declare function buildCommitPushResult(args: {
43
+ branch: string | null;
44
+ commitHash: string;
45
+ commitMessage: string;
46
+ filesStaged: string[];
47
+ pushed: boolean;
48
+ error?: string;
49
+ }): CommitPushResult;
50
+ /**
51
+ * git commit-push: stage, commit, and push in one operation.
52
+ * Skips push when on a protected branch (develop, main).
53
+ * Returns JSON for programmatic consumption by AI agents.
54
+ *
55
+ * @param options - Command options (message, files, issue, verbose)
56
+ * @param logger - Logger instance for debug/warn output
57
+ * @returns Exit code (0 = success, 1 = error)
58
+ */
59
+ export declare function cmdGitCommitPush(options: CommitPushOptions, logger: Logger): Promise<number>;
60
+ //# sourceMappingURL=commit-push.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-push.d.ts","sourceRoot":"","sources":["../../../src/commands/git/commit-push.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAO/C,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKrF;AAMD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,gBAAgB,CAUnB;AAMD;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAsEjB"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * git commit-push - Stage, commit, and push in a single command
3
+ *
4
+ * Consolidates git add + commit + push into one operation for AI agents,
5
+ * reducing context window usage (3 commands → 1).
6
+ *
7
+ * Usage:
8
+ * shirokuma-docs git commit-push -m "fix: タイポを修正" --issue 1416
9
+ * shirokuma-docs git commit-push -m "fix: タイポを修正" -f src/index.ts -f src/utils.ts
10
+ */
11
+ import { simpleGit } from "simple-git";
12
+ import { PROTECTED_BRANCHES } from "../session/utils.js";
13
+ // =============================================================================
14
+ // buildCommitMessage - Pure function (testable)
15
+ // =============================================================================
16
+ /**
17
+ * Build commit message, optionally appending issue reference (#N).
18
+ * Skips appending if the reference already exists in the message.
19
+ *
20
+ * @param message - Base commit message
21
+ * @param issue - Issue number to append as (#N), or undefined to skip
22
+ * @returns Commit message with optional issue reference
23
+ */
24
+ export function buildCommitMessage(message, issue) {
25
+ if (issue === undefined)
26
+ return message;
27
+ const ref = `(#${issue})`;
28
+ if (message.includes(ref))
29
+ return message;
30
+ return `${message} ${ref}`;
31
+ }
32
+ // =============================================================================
33
+ // buildCommitPushResult - Pure function (testable)
34
+ // =============================================================================
35
+ /**
36
+ * Assemble CommitPushResult from commit operation data.
37
+ * Pure function - no I/O, fully testable.
38
+ *
39
+ * @param args - Commit operation data fields
40
+ * @returns Structured result for JSON output
41
+ */
42
+ export function buildCommitPushResult(args) {
43
+ const result = {
44
+ branch: args.branch,
45
+ commit_hash: args.commitHash,
46
+ commit_message: args.commitMessage,
47
+ files_staged: args.filesStaged,
48
+ pushed: args.pushed,
49
+ };
50
+ if (args.error !== undefined)
51
+ result.error = args.error;
52
+ return result;
53
+ }
54
+ // =============================================================================
55
+ // cmdGitCommitPush - Command handler
56
+ // =============================================================================
57
+ /**
58
+ * git commit-push: stage, commit, and push in one operation.
59
+ * Skips push when on a protected branch (develop, main).
60
+ * Returns JSON for programmatic consumption by AI agents.
61
+ *
62
+ * @param options - Command options (message, files, issue, verbose)
63
+ * @param logger - Logger instance for debug/warn output
64
+ * @returns Exit code (0 = success, 1 = error)
65
+ */
66
+ export async function cmdGitCommitPush(options, logger) {
67
+ const git = simpleGit();
68
+ // 1. Get current branch
69
+ const branchSummary = await git.branch();
70
+ const branch = branchSummary.current || null;
71
+ logger.debug(`Branch: ${branch ?? "(detached)"}`);
72
+ const isProtected = branch !== null && PROTECTED_BRANCHES.includes(branch);
73
+ if (isProtected) {
74
+ logger.warn(`On protected branch "${branch}". Push will be skipped.`);
75
+ }
76
+ // 2. Stage files
77
+ const filesArg = options.files && options.files.length > 0 ? options.files : ["."];
78
+ await git.add(filesArg);
79
+ // Collect staged file list for output
80
+ const statusSummary = await git.status();
81
+ const filesStaged = statusSummary.staged;
82
+ logger.debug(`Staged files: ${filesStaged.join(", ") || "(none)"}`);
83
+ if (filesStaged.length === 0) {
84
+ logger.warn("Nothing to commit: no staged changes after git add.");
85
+ console.log(JSON.stringify({ error: "nothing to commit", files_staged: [] }, null, 2));
86
+ return 1;
87
+ }
88
+ // 3. Build commit message
89
+ const commitMessage = buildCommitMessage(options.message, options.issue);
90
+ logger.debug(`Commit message: ${commitMessage}`);
91
+ // 4. Commit
92
+ let commitHash;
93
+ try {
94
+ const commitResult = await git.commit(commitMessage);
95
+ commitHash = (commitResult.commit ?? "").substring(0, 7);
96
+ logger.debug(`Committed: ${commitHash}`);
97
+ }
98
+ catch (e) {
99
+ logger.warn(`Commit failed: ${e}`);
100
+ console.log(JSON.stringify({ error: `commit failed: ${String(e)}`, files_staged: filesStaged }, null, 2));
101
+ return 1;
102
+ }
103
+ // 5. Push (skip on protected branches)
104
+ let pushed = false;
105
+ let pushError;
106
+ if (!isProtected && branch) {
107
+ try {
108
+ await git.push("origin", branch, ["--set-upstream"]);
109
+ pushed = true;
110
+ logger.debug(`Pushed to origin/${branch}`);
111
+ }
112
+ catch (e) {
113
+ pushError = String(e);
114
+ logger.warn(`Push failed: ${e}`);
115
+ }
116
+ }
117
+ // 6. Build and print result
118
+ const result = buildCommitPushResult({
119
+ branch,
120
+ commitHash,
121
+ commitMessage,
122
+ filesStaged,
123
+ pushed,
124
+ error: pushError,
125
+ });
126
+ console.log(JSON.stringify(result, null, 2));
127
+ return pushError !== undefined ? 1 : 0;
128
+ }
129
+ //# sourceMappingURL=commit-push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-push.js","sourceRoot":"","sources":["../../../src/commands/git/commit-push.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAsBzD,gFAAgF;AAChF,gDAAgD;AAChD,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,KAAyB;IAC3E,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,KAAK,GAAG,CAAC;IAC1B,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAC1C,OAAO,GAAG,OAAO,IAAI,GAAG,EAAE,CAAC;AAC7B,CAAC;AAED,gFAAgF;AAChF,mDAAmD;AACnD,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAOrC;IACC,MAAM,MAAM,GAAqB;QAC/B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,WAAW,EAAE,IAAI,CAAC,UAAU;QAC5B,cAAc,EAAE,IAAI,CAAC,aAAa;QAClC,YAAY,EAAE,IAAI,CAAC,WAAW;QAC9B,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC;IACF,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CA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oBAAoB,MAAM,EAAE,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,MAAM,MAAM,GAAG,qBAAqB,CAAC;QACnC,MAAM;QACN,UAAU;QACV,aAAa;QACb,WAAW;QACX,MAAM;QACN,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7C,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shirokuma-library/shirokuma-docs",
3
- "version": "0.3.0-alpha.19",
3
+ "version": "0.3.0-alpha.20",
4
4
  "description": "Next.js プロジェクト用ドキュメント自動生成 CLI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",