@savvy-web/cli 1.1.1 → 1.1.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/README.md +1 -1
- package/cli/index.js +1 -1
- package/commands/commit/hook.js +1 -3
- package/commands/lint/init.js +15 -13
- package/package.json +2 -2
- package/commands/commit/hooks/user-prompt-submit.js +0 -42
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ npx savvy clean --globs dist,.turbo,coverage
|
|
|
52
52
|
- `savvy init` — orchestrator that runs changeset, commit and lint setup in one pass.
|
|
53
53
|
- `savvy check` — orchestrator that runs all three checks and reports every failure (it does not short-circuit).
|
|
54
54
|
- `savvy clean` — removes build and cache artifacts (`dist`, `.turbo`, `coverage`, `node_modules`, `.rslib` by default) from every workspace package (leaves first) and the repo root (last); `--globs` to customize, `--dry-run` to preview.
|
|
55
|
-
- `savvy commit` — the husky/Claude hook handlers (session-start, pre-commit-message, post-commit-verify
|
|
55
|
+
- `savvy commit` — the husky/Claude hook handlers (session-start, pre-commit-message, post-commit-verify).
|
|
56
56
|
- `savvy changeset` — changeset lint, check, transform, version, config validation, and dependency changesets.
|
|
57
57
|
- `savvy lint` — formatters for package.json, the pnpm workspace file and YAML.
|
|
58
58
|
|
package/cli/index.js
CHANGED
|
@@ -56,7 +56,7 @@ const rootCommand = Command.make("savvy").pipe(Command.withSubcommands([
|
|
|
56
56
|
]));
|
|
57
57
|
const cli = Command.run(rootCommand, {
|
|
58
58
|
name: "savvy",
|
|
59
|
-
version: "1.1.
|
|
59
|
+
version: "1.1.2"
|
|
60
60
|
});
|
|
61
61
|
/**
|
|
62
62
|
* Shared base layer: workspace services, the changeset config reader, and the
|
package/commands/commit/hook.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { postCommitVerifyCommand } from "./hooks/post-commit-verify.js";
|
|
2
2
|
import { preCommitMessageCommand } from "./hooks/pre-commit-message.js";
|
|
3
3
|
import { sessionStartCommand } from "./hooks/session-start.js";
|
|
4
|
-
import { userPromptSubmitCommand } from "./hooks/user-prompt-submit.js";
|
|
5
4
|
import { Command } from "@effect/cli";
|
|
6
5
|
|
|
7
6
|
//#region src/commands/commit/hook.ts
|
|
@@ -14,8 +13,7 @@ import { Command } from "@effect/cli";
|
|
|
14
13
|
const hookCommand = Command.make("hook").pipe(Command.withSubcommands([
|
|
15
14
|
sessionStartCommand,
|
|
16
15
|
preCommitMessageCommand,
|
|
17
|
-
postCommitVerifyCommand
|
|
18
|
-
userPromptSubmitCommand
|
|
16
|
+
postCommitVerifyCommand
|
|
19
17
|
])).pipe(Command.withDescription("Internal hook handlers used by the @savvy-web/commitlint plugin"));
|
|
20
18
|
|
|
21
19
|
//#endregion
|
package/commands/lint/init.js
CHANGED
|
@@ -91,25 +91,27 @@ function writeMarkdownlintConfig(fs, preset, force) {
|
|
|
91
91
|
const existingText = yield* fs.readFileString(Lint.MARKDOWNLINT_CONFIG_PATH);
|
|
92
92
|
const existingParsed = yield* parse(existingText);
|
|
93
93
|
let updatedText = existingText;
|
|
94
|
-
|
|
94
|
+
const applied = [];
|
|
95
95
|
if (existingParsed.$schema !== Lint.MARKDOWNLINT_SCHEMA) {
|
|
96
96
|
const edits = yield* modify(updatedText, ["$schema"], Lint.MARKDOWNLINT_SCHEMA, { formattingOptions: JSONC_FORMAT });
|
|
97
97
|
updatedText = yield* applyEdits(updatedText, edits);
|
|
98
|
-
|
|
98
|
+
applied.push("$schema");
|
|
99
99
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
return;
|
|
100
|
+
const existingIgnores = Array.isArray(existingParsed.ignores) ? existingParsed.ignores : [];
|
|
101
|
+
const missingIgnores = Lint.MARKDOWNLINT_TEMPLATE.ignores.filter((glob) => !existingIgnores.includes(glob));
|
|
102
|
+
if (missingIgnores.length > 0) {
|
|
103
|
+
const mergedIgnores = [...existingIgnores, ...missingIgnores];
|
|
104
|
+
const edits = yield* modify(updatedText, ["ignores"], mergedIgnores, { formattingOptions: JSONC_FORMAT });
|
|
105
|
+
updatedText = yield* applyEdits(updatedText, edits);
|
|
106
|
+
applied.push(`ignores (+${missingIgnores.length})`);
|
|
108
107
|
}
|
|
109
|
-
|
|
108
|
+
const existingConfig = existingParsed.config;
|
|
109
|
+
const configMatches = existingConfig !== void 0 && isDeepStrictEqual(existingConfig, Lint.MARKDOWNLINT_CONFIG);
|
|
110
|
+
if (!configMatches) yield* Effect.log(`${WARNING} ${Lint.MARKDOWNLINT_CONFIG_PATH}: config rules differ from template (use --force to overwrite)`);
|
|
111
|
+
if (applied.length > 0) {
|
|
110
112
|
yield* fs.writeFileString(Lint.MARKDOWNLINT_CONFIG_PATH, updatedText);
|
|
111
|
-
yield* Effect.log(`${CHECK_MARK} Updated $
|
|
112
|
-
} else yield* Effect.log(`${CHECK_MARK} ${Lint.MARKDOWNLINT_CONFIG_PATH}: up-to-date`);
|
|
113
|
+
yield* Effect.log(`${CHECK_MARK} Updated ${applied.join(", ")} in ${Lint.MARKDOWNLINT_CONFIG_PATH}`);
|
|
114
|
+
} else if (configMatches) yield* Effect.log(`${CHECK_MARK} ${Lint.MARKDOWNLINT_CONFIG_PATH}: up-to-date`);
|
|
113
115
|
});
|
|
114
116
|
}
|
|
115
117
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The savvy CLI — unified commit, changeset, and lint commands for the Silk Suite",
|
|
6
6
|
"homepage": "https://github.com/savvy-web/systems/tree/main/packages/cli",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@effect/platform-node": "^0.107.0",
|
|
37
37
|
"@effect/rpc": "^0.75.1",
|
|
38
38
|
"@effect/sql": "^0.51.1",
|
|
39
|
-
"@savvy-web/silk-effects": "1.3.
|
|
39
|
+
"@savvy-web/silk-effects": "1.3.1",
|
|
40
40
|
"effect": "^3.21.3",
|
|
41
41
|
"jsonc-effect": "^0.2.1",
|
|
42
42
|
"workspaces-effect": "^1.2.0",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Command } from "@effect/cli";
|
|
2
|
-
import { Commitlint } from "@savvy-web/silk-effects";
|
|
3
|
-
import { Effect, Schema } from "effect";
|
|
4
|
-
|
|
5
|
-
//#region src/commands/commit/hooks/user-prompt-submit.ts
|
|
6
|
-
/**
|
|
7
|
-
* `savvy commit hook user-prompt-submit` — emits a compact reminder when
|
|
8
|
-
* the prompt mentions commit-related verbs.
|
|
9
|
-
*
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
const TRIGGER = /(\bcommit\b|\bcommitting\b|\bship (it|this)\b|\bwrap (it )?up\b|\b(create|open) a (pr|pull request)\b|\bfinalize\b|\/finalize\b|\bsquash\b|\bamend\b)/i;
|
|
13
|
-
function reminderForPrompt(prompt) {
|
|
14
|
-
if (!TRIGGER.test(prompt)) return null;
|
|
15
|
-
return [
|
|
16
|
-
"<commit_reminder>",
|
|
17
|
-
"Before composing this commit message, invoke the commitlint:commit-create skill.",
|
|
18
|
-
"It defines the complete type enum, scope rules, DCO signoff format, and body",
|
|
19
|
-
"constraints enforced by @savvy-web/commitlint.",
|
|
20
|
-
"</commit_reminder>"
|
|
21
|
-
].join("\n");
|
|
22
|
-
}
|
|
23
|
-
const userPromptSubmitCommand = Command.make("user-prompt-submit", {}, () => Effect.gen(function* () {
|
|
24
|
-
const stdin = yield* Effect.promise(readStdin);
|
|
25
|
-
let envelope;
|
|
26
|
-
try {
|
|
27
|
-
envelope = Schema.decodeUnknownSync(Commitlint.UserPromptSubmitEnvelope)(JSON.parse(stdin));
|
|
28
|
-
} catch {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const reminder = reminderForPrompt(envelope.prompt);
|
|
32
|
-
if (reminder === null) return;
|
|
33
|
-
yield* Effect.sync(() => process.stdout.write(`${JSON.stringify(Commitlint.userPromptSubmitContext(reminder))}\n`));
|
|
34
|
-
}).pipe(Effect.provide(Commitlint.HookSilencer))).pipe(Command.withDescription("Inject a commit-quality reminder when the user prompt mentions commits"));
|
|
35
|
-
async function readStdin() {
|
|
36
|
-
const chunks = [];
|
|
37
|
-
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
38
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { userPromptSubmitCommand };
|