@staff0rd/assist 0.328.0 → 0.329.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 (2) hide show
  1. package/dist/index.js +24 -14
  2. package/package.json +1 -1
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.328.0",
9
+ version: "0.329.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -11514,6 +11514,29 @@ function extractComments(text6) {
11514
11514
  return comments3.map((comment3) => comment3.replace(/\s+/g, " ").trim()).filter((comment3) => comment3.length > 0).filter((comment3) => !isCommentExempt(comment3));
11515
11515
  }
11516
11516
 
11517
+ // src/commands/editHook/introducedComments.ts
11518
+ function introducedComments(added, removed) {
11519
+ const counts = /* @__PURE__ */ new Map();
11520
+ for (const comment3 of removed) {
11521
+ counts.set(comment3, (counts.get(comment3) ?? 0) + 1);
11522
+ }
11523
+ const candidates = [];
11524
+ for (const comment3 of added) {
11525
+ const remaining = counts.get(comment3) ?? 0;
11526
+ if (remaining > 0) counts.set(comment3, remaining - 1);
11527
+ else candidates.push(comment3);
11528
+ }
11529
+ const removedWords = new Set(removed.flatMap(commentWords));
11530
+ return candidates.filter((comment3) => {
11531
+ const words = commentWords(comment3);
11532
+ if (words.length === 0) return true;
11533
+ return !words.every((word) => removedWords.has(word));
11534
+ });
11535
+ }
11536
+ function commentWords(comment3) {
11537
+ return comment3.toLowerCase().split(/[^a-z0-9]+/).filter((word) => word.length > 0);
11538
+ }
11539
+
11517
11540
  // src/commands/editHook/decideCommentGuard.ts
11518
11541
  var DENY_REASON = 'This edit introduces a code comment, which is blocked by the comment gate. Comments are a last resort \u2014 prefer a clearer name, a smaller function, or a test that makes the comment unnecessary. The comment must not appear in your edit itself. If this one line genuinely earns its keep, use the escape hatch: run `assist code-comment set <file> <line> "<text>"` (single line, max 50 chars, no block comments) to get a pin, then `assist code-comment confirm <pin>` to insert it.';
11519
11542
  function defined(values) {
@@ -11543,19 +11566,6 @@ function partitionStrings(input, existingContent) {
11543
11566
  return { added: [], removed: [] };
11544
11567
  }
11545
11568
  }
11546
- function introducedComments(added, removed) {
11547
- const counts = /* @__PURE__ */ new Map();
11548
- for (const comment3 of removed) {
11549
- counts.set(comment3, (counts.get(comment3) ?? 0) + 1);
11550
- }
11551
- const introduced = [];
11552
- for (const comment3 of added) {
11553
- const remaining = counts.get(comment3) ?? 0;
11554
- if (remaining > 0) counts.set(comment3, remaining - 1);
11555
- else introduced.push(comment3);
11556
- }
11557
- return introduced;
11558
- }
11559
11569
  function decideCommentGuard(input, existingContent) {
11560
11570
  if (!isSourceFile(input.tool_input.file_path)) return void 0;
11561
11571
  const { added, removed } = partitionStrings(input, existingContent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.328.0",
3
+ "version": "0.329.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {