@staff0rd/assist 0.89.2 → 0.91.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/claude/commands/commit.md +6 -4
- package/dist/index.js +48 -17
- package/package.json +1 -1
|
@@ -4,8 +4,10 @@ description: Commit only relevant files from the session
|
|
|
4
4
|
|
|
5
5
|
Review the git status and create a commit with only the files that are relevant to the current session. Write a clear, concise commit message that describes what changed and why. Do not reference Claude or any AI assistance in the commit message.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 40 characters or less
|
|
9
|
-
- Does not reference Claude
|
|
7
|
+
First run `assist commit status` to see the current state of the working tree.
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
Then use `assist commit <file1> <file2> ... "your message"` where:
|
|
10
|
+
- Each file argument is a path to git add before committing
|
|
11
|
+
- The last argument is the commit message
|
|
12
|
+
- The commit message is 40 characters or less
|
|
13
|
+
- The commit message does not reference Claude
|
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.91.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -220,8 +220,7 @@ function getTranscriptConfig() {
|
|
|
220
220
|
// src/commands/commit.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
|
-
function
|
|
224
|
-
const config = loadConfig();
|
|
223
|
+
function validateMessage(message, config) {
|
|
225
224
|
if (message.toLowerCase().includes("claude")) {
|
|
226
225
|
console.error("Error: Commit message must not reference Claude");
|
|
227
226
|
process.exit(1);
|
|
@@ -238,16 +237,24 @@ function commit(message) {
|
|
|
238
237
|
);
|
|
239
238
|
process.exit(1);
|
|
240
239
|
}
|
|
240
|
+
}
|
|
241
|
+
function escapeShell(s) {
|
|
242
|
+
return `"${s.replace(/"/g, '\\"')}"`;
|
|
243
|
+
}
|
|
244
|
+
function stageAndCommit(files, message) {
|
|
245
|
+
const escaped = files.map(escapeShell).join(" ");
|
|
246
|
+
execSync(`git add ${escaped}`, { stdio: "inherit" });
|
|
247
|
+
execSync(`git commit -m ${escapeShell(message)}`, { stdio: "inherit" });
|
|
248
|
+
return execSync("git rev-parse --short=7 HEAD", {
|
|
249
|
+
encoding: "utf-8"
|
|
250
|
+
}).trim();
|
|
251
|
+
}
|
|
252
|
+
function execCommit(files, message, config) {
|
|
241
253
|
try {
|
|
242
254
|
if (config.commit?.pull) {
|
|
243
255
|
execSync("git pull", { stdio: "inherit" });
|
|
244
256
|
}
|
|
245
|
-
|
|
246
|
-
stdio: "inherit"
|
|
247
|
-
});
|
|
248
|
-
const sha = execSync("git rev-parse --short=7 HEAD", {
|
|
249
|
-
encoding: "utf-8"
|
|
250
|
-
}).trim();
|
|
257
|
+
const sha = stageAndCommit(files, message);
|
|
251
258
|
console.log(`Committed: ${sha}`);
|
|
252
259
|
if (config.commit?.push) {
|
|
253
260
|
execSync("git push", { stdio: "inherit" });
|
|
@@ -258,6 +265,23 @@ function commit(message) {
|
|
|
258
265
|
process.exit(1);
|
|
259
266
|
}
|
|
260
267
|
}
|
|
268
|
+
function commit(args) {
|
|
269
|
+
if (args[0] === "status") {
|
|
270
|
+
execSync("git status && echo '---DIFF---' && git diff", {
|
|
271
|
+
stdio: "inherit"
|
|
272
|
+
});
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (args.length < 2) {
|
|
276
|
+
console.error("Usage: assist commit <files...> <message>");
|
|
277
|
+
process.exit(1);
|
|
278
|
+
}
|
|
279
|
+
const message = args[args.length - 1];
|
|
280
|
+
const files = args.slice(0, -1);
|
|
281
|
+
const config = loadConfig();
|
|
282
|
+
validateMessage(message, config);
|
|
283
|
+
execCommit(files, message, config);
|
|
284
|
+
}
|
|
261
285
|
|
|
262
286
|
// src/commands/config/index.ts
|
|
263
287
|
import chalk2 from "chalk";
|
|
@@ -5970,9 +5994,16 @@ function run2(name, args) {
|
|
|
5970
5994
|
}
|
|
5971
5995
|
|
|
5972
5996
|
// src/commands/statusLine.ts
|
|
5997
|
+
import chalk52 from "chalk";
|
|
5973
5998
|
function formatNumber(num) {
|
|
5974
5999
|
return num.toLocaleString("en-US");
|
|
5975
6000
|
}
|
|
6001
|
+
function colorizePercent(pct) {
|
|
6002
|
+
const label2 = `${pct}%`;
|
|
6003
|
+
if (pct > 80) return chalk52.red(label2);
|
|
6004
|
+
if (pct > 40) return chalk52.yellow(label2);
|
|
6005
|
+
return label2;
|
|
6006
|
+
}
|
|
5976
6007
|
async function statusLine() {
|
|
5977
6008
|
const inputData = await readStdin();
|
|
5978
6009
|
const data = JSON.parse(inputData);
|
|
@@ -5983,7 +6014,7 @@ async function statusLine() {
|
|
|
5983
6014
|
const formattedInput = formatNumber(totalInput);
|
|
5984
6015
|
const formattedOutput = formatNumber(totalOutput);
|
|
5985
6016
|
console.log(
|
|
5986
|
-
`${model} | Tokens - ${formattedOutput} \u2191 : ${formattedInput} \u2193 | Context - ${usedPct}
|
|
6017
|
+
`${model} | Tokens - ${formattedOutput} \u2191 : ${formattedInput} \u2193 | Context - ${colorizePercent(usedPct)}`
|
|
5987
6018
|
);
|
|
5988
6019
|
}
|
|
5989
6020
|
|
|
@@ -5996,7 +6027,7 @@ import { fileURLToPath as fileURLToPath5 } from "url";
|
|
|
5996
6027
|
// src/commands/sync/syncClaudeMd.ts
|
|
5997
6028
|
import * as fs21 from "fs";
|
|
5998
6029
|
import * as path27 from "path";
|
|
5999
|
-
import
|
|
6030
|
+
import chalk53 from "chalk";
|
|
6000
6031
|
async function syncClaudeMd(claudeDir, targetBase) {
|
|
6001
6032
|
const source = path27.join(claudeDir, "CLAUDE.md");
|
|
6002
6033
|
const target = path27.join(targetBase, "CLAUDE.md");
|
|
@@ -6005,12 +6036,12 @@ async function syncClaudeMd(claudeDir, targetBase) {
|
|
|
6005
6036
|
const targetContent = fs21.readFileSync(target, "utf-8");
|
|
6006
6037
|
if (sourceContent !== targetContent) {
|
|
6007
6038
|
console.log(
|
|
6008
|
-
|
|
6039
|
+
chalk53.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
6009
6040
|
);
|
|
6010
6041
|
console.log();
|
|
6011
6042
|
printDiff(targetContent, sourceContent);
|
|
6012
6043
|
const confirm = await promptConfirm(
|
|
6013
|
-
|
|
6044
|
+
chalk53.red("Overwrite existing CLAUDE.md?"),
|
|
6014
6045
|
false
|
|
6015
6046
|
);
|
|
6016
6047
|
if (!confirm) {
|
|
@@ -6026,7 +6057,7 @@ async function syncClaudeMd(claudeDir, targetBase) {
|
|
|
6026
6057
|
// src/commands/sync/syncSettings.ts
|
|
6027
6058
|
import * as fs22 from "fs";
|
|
6028
6059
|
import * as path28 from "path";
|
|
6029
|
-
import
|
|
6060
|
+
import chalk54 from "chalk";
|
|
6030
6061
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
6031
6062
|
const source = path28.join(claudeDir, "settings.json");
|
|
6032
6063
|
const target = path28.join(targetBase, "settings.json");
|
|
@@ -6038,14 +6069,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
6038
6069
|
if (normalizedSource !== normalizedTarget) {
|
|
6039
6070
|
if (!options2?.yes) {
|
|
6040
6071
|
console.log(
|
|
6041
|
-
|
|
6072
|
+
chalk54.yellow(
|
|
6042
6073
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
6043
6074
|
)
|
|
6044
6075
|
);
|
|
6045
6076
|
console.log();
|
|
6046
6077
|
printDiff(targetContent, sourceContent);
|
|
6047
6078
|
const confirm = await promptConfirm(
|
|
6048
|
-
|
|
6079
|
+
chalk54.red("Overwrite existing settings.json?"),
|
|
6049
6080
|
false
|
|
6050
6081
|
);
|
|
6051
6082
|
if (!confirm) {
|
|
@@ -6137,7 +6168,7 @@ var program = new Command();
|
|
|
6137
6168
|
program.name("assist").description("CLI application").version(package_default.version);
|
|
6138
6169
|
program.command("sync").description("Copy command files to ~/.claude/commands").option("-y, --yes", "Overwrite settings.json without prompting").action((options2) => sync(options2));
|
|
6139
6170
|
program.command("init").description("Initialize VS Code and verify configurations").action(init4);
|
|
6140
|
-
program.command("commit
|
|
6171
|
+
program.command("commit").description("Create a git commit with validation").argument("<args...>", "status | <files...> <message>").action(commit);
|
|
6141
6172
|
var configCommand = program.command("config").description("View and modify assist.yml configuration");
|
|
6142
6173
|
configCommand.command("set <key> <value>").description("Set a config value (e.g. commit.push true)").action(configSet);
|
|
6143
6174
|
configCommand.command("get <key>").description("Get a config value").action(configGet);
|