@staff0rd/assist 0.147.0 → 0.147.2
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/test-cover.md +1 -1
- package/claude/commands/test-review.md +1 -1
- package/dist/index.js +37 -15
- package/package.json +1 -1
|
@@ -51,7 +51,7 @@ Use a behavioural, BDD-style structure:
|
|
|
51
51
|
|
|
52
52
|
- **Outer `describe`** — the function or module under test
|
|
53
53
|
- **Inner `describe("when ...")`** — groups tests that share the same setup/scenario
|
|
54
|
-
- **`it("should ...")`** — asserts a single rule or behaviour
|
|
54
|
+
- **`it("should ...")`** — asserts a single rule or behaviour. State specifiers (flags, syntax variants, conditions) belong in `when` blocks, never in `it` descriptions — keep assertions as bare outcomes (e.g. "should allow", "should reject")
|
|
55
55
|
|
|
56
56
|
Each test follows an **Arrange, Act, Assert** pattern. Do NOT add `// arrange`, `// act`, `// assert` comments — just structure the code in that order with whitespace separating the three sections.
|
|
57
57
|
|
|
@@ -35,7 +35,7 @@ Assess each test file against these criteria:
|
|
|
35
35
|
### BDD structure and Arrange-Act-Assert
|
|
36
36
|
- Does the outer `describe` name the function or module under test?
|
|
37
37
|
- Do inner `describe("when ...")` blocks group tests by shared setup/scenario?
|
|
38
|
-
- Do `it` blocks use `should` phrasing (e.g., `it("should
|
|
38
|
+
- Do `it` blocks use `should` phrasing with bare outcomes (e.g., `it("should allow")`, `it("should reject")`)? State specifiers (flags, syntax variants, conditions) belong in `when` blocks, never in `it` descriptions.
|
|
39
39
|
- Does each test follow Arrange, Act, Assert ordering (without comments labelling the sections)?
|
|
40
40
|
- Are assertions minimal per test — ideally one, at most two closely related? If multiple things are asserted about the same action, are they split into separate `it` blocks under the same `describe("when ...")`?
|
|
41
41
|
|
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.147.
|
|
9
|
+
version: "0.147.2",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -7290,6 +7290,18 @@ async function applyExtraction(functionName, sourceFile, destPath, plan2, projec
|
|
|
7290
7290
|
}
|
|
7291
7291
|
updateImporters(functionName, sourceFile, plan2.importersToUpdate);
|
|
7292
7292
|
if (plan2.barrel) {
|
|
7293
|
+
for (const decl of plan2.barrel.getExportDeclarations()) {
|
|
7294
|
+
const named = decl.getNamedExports();
|
|
7295
|
+
const match = named.find((n) => n.getName() === functionName);
|
|
7296
|
+
if (match) {
|
|
7297
|
+
if (named.length === 1) {
|
|
7298
|
+
decl.remove();
|
|
7299
|
+
} else {
|
|
7300
|
+
match.remove();
|
|
7301
|
+
}
|
|
7302
|
+
break;
|
|
7303
|
+
}
|
|
7304
|
+
}
|
|
7293
7305
|
plan2.barrel.addExportDeclaration({
|
|
7294
7306
|
moduleSpecifier: plan2.barrelRelPath,
|
|
7295
7307
|
namedExports: [functionName]
|
|
@@ -7298,9 +7310,6 @@ async function applyExtraction(functionName, sourceFile, destPath, plan2, projec
|
|
|
7298
7310
|
await project.save();
|
|
7299
7311
|
}
|
|
7300
7312
|
|
|
7301
|
-
// src/commands/refactor/extract/buildPlan.ts
|
|
7302
|
-
import path29 from "path";
|
|
7303
|
-
|
|
7304
7313
|
// src/commands/refactor/extract/collectDependencies.ts
|
|
7305
7314
|
import {
|
|
7306
7315
|
SyntaxKind as SyntaxKind5
|
|
@@ -7628,6 +7637,26 @@ function findImporters(functionName, sourceFile, destPath, project) {
|
|
|
7628
7637
|
return result;
|
|
7629
7638
|
}
|
|
7630
7639
|
|
|
7640
|
+
// src/commands/refactor/extract/resolveBarrel.ts
|
|
7641
|
+
import path29 from "path";
|
|
7642
|
+
function resolveBarrel(functionName, sourcePath, destPath, project) {
|
|
7643
|
+
const indexPath = path29.join(path29.dirname(destPath), "index.ts");
|
|
7644
|
+
const barrel = project.getSourceFile(indexPath);
|
|
7645
|
+
if (!barrel) return { barrel: void 0, barrelRelPath: "" };
|
|
7646
|
+
const sourceRelFromBarrel = getRelativeImportPath(indexPath, sourcePath);
|
|
7647
|
+
const alreadyExported = barrel.getExportDeclarations().some((decl) => {
|
|
7648
|
+
const specifier = decl.getModuleSpecifierValue();
|
|
7649
|
+
if (specifier !== sourceRelFromBarrel) return false;
|
|
7650
|
+
const named = decl.getNamedExports();
|
|
7651
|
+
return named.some((n) => n.getName() === functionName);
|
|
7652
|
+
});
|
|
7653
|
+
if (!alreadyExported) return { barrel: void 0, barrelRelPath: "" };
|
|
7654
|
+
return {
|
|
7655
|
+
barrel,
|
|
7656
|
+
barrelRelPath: getRelativeImportPath(indexPath, destPath)
|
|
7657
|
+
};
|
|
7658
|
+
}
|
|
7659
|
+
|
|
7631
7660
|
// src/commands/refactor/extract/sourceReferencesName.ts
|
|
7632
7661
|
import { SyntaxKind as SyntaxKind10 } from "ts-morph";
|
|
7633
7662
|
var DECLARATION_KINDS = /* @__PURE__ */ new Set([
|
|
@@ -7660,13 +7689,6 @@ function sourceReferencesName(sourceFile, functionName, extractedNames) {
|
|
|
7660
7689
|
}
|
|
7661
7690
|
|
|
7662
7691
|
// src/commands/refactor/extract/buildPlan.ts
|
|
7663
|
-
function resolveBarrel(destPath, project) {
|
|
7664
|
-
const indexPath = path29.join(path29.dirname(destPath), "index.ts");
|
|
7665
|
-
return {
|
|
7666
|
-
barrel: project.getSourceFile(indexPath),
|
|
7667
|
-
barrelRelPath: getRelativeImportPath(indexPath, destPath)
|
|
7668
|
-
};
|
|
7669
|
-
}
|
|
7670
7692
|
function buildPlan(functionName, sourceFile, sourcePath, destPath, project) {
|
|
7671
7693
|
const analysis = analyseTarget(sourceFile, functionName);
|
|
7672
7694
|
const sourceRelPath = getRelativeImportPath(destPath, sourcePath);
|
|
@@ -7687,7 +7709,7 @@ function buildPlan(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
7687
7709
|
analysis.extractedNames
|
|
7688
7710
|
),
|
|
7689
7711
|
importersToUpdate: analysis.target.isExported() ? findImporters(functionName, sourceFile, destPath, project) : [],
|
|
7690
|
-
...resolveBarrel(destPath, project)
|
|
7712
|
+
...resolveBarrel(functionName, sourcePath, destPath, project)
|
|
7691
7713
|
};
|
|
7692
7714
|
}
|
|
7693
7715
|
|
|
@@ -10254,7 +10276,7 @@ import { fileURLToPath as fileURLToPath7 } from "url";
|
|
|
10254
10276
|
import * as fs23 from "fs";
|
|
10255
10277
|
import * as path45 from "path";
|
|
10256
10278
|
import chalk105 from "chalk";
|
|
10257
|
-
async function syncClaudeMd(claudeDir, targetBase) {
|
|
10279
|
+
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
10258
10280
|
const source = path45.join(claudeDir, "CLAUDE.md");
|
|
10259
10281
|
const target = path45.join(targetBase, "CLAUDE.md");
|
|
10260
10282
|
const sourceContent = fs23.readFileSync(source, "utf-8");
|
|
@@ -10266,7 +10288,7 @@ async function syncClaudeMd(claudeDir, targetBase) {
|
|
|
10266
10288
|
);
|
|
10267
10289
|
console.log();
|
|
10268
10290
|
printDiff(targetContent, sourceContent);
|
|
10269
|
-
const confirm = await promptConfirm(
|
|
10291
|
+
const confirm = options2?.yes || await promptConfirm(
|
|
10270
10292
|
chalk105.red("Overwrite existing CLAUDE.md?"),
|
|
10271
10293
|
false
|
|
10272
10294
|
);
|
|
@@ -10328,7 +10350,7 @@ async function sync(options2) {
|
|
|
10328
10350
|
const targetBase = path47.join(os.homedir(), ".claude");
|
|
10329
10351
|
syncCommands(claudeDir, targetBase);
|
|
10330
10352
|
await syncSettings(claudeDir, targetBase, { yes: options2?.yes });
|
|
10331
|
-
await syncClaudeMd(claudeDir, targetBase);
|
|
10353
|
+
await syncClaudeMd(claudeDir, targetBase, { yes: options2?.yes });
|
|
10332
10354
|
}
|
|
10333
10355
|
function syncCommands(claudeDir, targetBase) {
|
|
10334
10356
|
const sourceDir = path47.join(claudeDir, "commands");
|