@staff0rd/assist 0.92.4 → 0.93.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.
- package/README.md +1 -0
- package/claude/commands/commit.md +5 -1
- package/dist/index.js +13 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ After installation, the `assist` command will be available globally. You can als
|
|
|
56
56
|
- `assist new cli` - Initialize a new tsup CLI project
|
|
57
57
|
- `assist sync` - Copy command files to `~/.claude/commands`
|
|
58
58
|
- `assist commit status` - Show git status and diff
|
|
59
|
+
- `assist commit <message>` - Commit staged changes with validation
|
|
59
60
|
- `assist commit <files...> <message>` - Stage files and create a git commit with validation
|
|
60
61
|
- `assist prs` - List pull requests for the current repository
|
|
61
62
|
- `assist prs list-comments` - List all comments on the current branch's pull request
|
|
@@ -6,7 +6,11 @@ Review the git status and create a commit with only the files that are relevant
|
|
|
6
6
|
|
|
7
7
|
First run `assist commit status` to see the current state of the working tree.
|
|
8
8
|
|
|
9
|
-
Then
|
|
9
|
+
Then either:
|
|
10
|
+
- `assist commit "your message"` to commit already-staged changes, or
|
|
11
|
+
- `assist commit <file1> <file2> ... "your message"` to stage files and commit
|
|
12
|
+
|
|
13
|
+
Where:
|
|
10
14
|
- Each file argument is a path to git add before committing
|
|
11
15
|
- The last argument is the commit message
|
|
12
16
|
- The commit message is 40 characters or less
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.93.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -217,7 +217,7 @@ function getTranscriptConfig() {
|
|
|
217
217
|
return config.transcript;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
// src/commands/commit.ts
|
|
220
|
+
// src/commands/commit/validateMessage.ts
|
|
221
221
|
var MAX_MESSAGE_LENGTH = 50;
|
|
222
222
|
var CONVENTIONAL_COMMIT_REGEX = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(!)?(\(.+\))?!?: .+$/;
|
|
223
223
|
function validateMessage(message, config) {
|
|
@@ -238,23 +238,28 @@ function validateMessage(message, config) {
|
|
|
238
238
|
process.exit(1);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
+
|
|
242
|
+
// src/commands/commit.ts
|
|
241
243
|
function escapeShell(s) {
|
|
242
244
|
return `"${s.replace(/"/g, '\\"')}"`;
|
|
243
245
|
}
|
|
244
|
-
function
|
|
245
|
-
const escaped = files.map(escapeShell).join(" ");
|
|
246
|
-
execSync(`git add ${escaped}`, { stdio: "inherit" });
|
|
246
|
+
function commitStaged(message) {
|
|
247
247
|
execSync(`git commit -m ${escapeShell(message)}`, { stdio: "inherit" });
|
|
248
248
|
return execSync("git rev-parse --short=7 HEAD", {
|
|
249
249
|
encoding: "utf-8"
|
|
250
250
|
}).trim();
|
|
251
251
|
}
|
|
252
|
+
function stageAndCommit(files, message) {
|
|
253
|
+
const escaped = files.map(escapeShell).join(" ");
|
|
254
|
+
execSync(`git add ${escaped}`, { stdio: "inherit" });
|
|
255
|
+
return commitStaged(message);
|
|
256
|
+
}
|
|
252
257
|
function execCommit(files, message, config) {
|
|
253
258
|
try {
|
|
254
259
|
if (config.commit?.pull) {
|
|
255
260
|
execSync("git pull", { stdio: "inherit" });
|
|
256
261
|
}
|
|
257
|
-
const sha = stageAndCommit(files, message);
|
|
262
|
+
const sha = files.length > 0 ? stageAndCommit(files, message) : commitStaged(message);
|
|
258
263
|
console.log(`Committed: ${sha}`);
|
|
259
264
|
if (config.commit?.push) {
|
|
260
265
|
execSync("git push", { stdio: "inherit" });
|
|
@@ -272,8 +277,8 @@ function commit(args) {
|
|
|
272
277
|
});
|
|
273
278
|
return;
|
|
274
279
|
}
|
|
275
|
-
if (args.length <
|
|
276
|
-
console.error("Usage: assist commit
|
|
280
|
+
if (args.length < 1) {
|
|
281
|
+
console.error("Usage: assist commit [files...] <message>");
|
|
277
282
|
process.exit(1);
|
|
278
283
|
}
|
|
279
284
|
const message = args[args.length - 1];
|