@wrongstack/plugins 0.284.1 → 0.286.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 +18 -14
- package/dist/accessibility-auditor/index.d.ts +38 -0
- package/dist/accessibility-auditor/index.d.ts.map +1 -0
- package/dist/accessibility-auditor.d.ts +2 -40
- package/dist/accessibility-auditor.js +10 -15
- package/dist/agent-handoff/index.d.ts +35 -0
- package/dist/agent-handoff/index.d.ts.map +1 -0
- package/dist/agent-handoff.d.ts +2 -37
- package/dist/agent-handoff.js +3 -2
- package/dist/api-compatibility-gate/index.d.ts +36 -0
- package/dist/api-compatibility-gate/index.d.ts.map +1 -0
- package/dist/api-compatibility-gate.d.ts +2 -38
- package/dist/api-compatibility-gate.js +6 -6
- package/dist/auto-doc/index.d.ts +20 -0
- package/dist/auto-doc/index.d.ts.map +1 -0
- package/dist/auto-doc.d.ts +2 -22
- package/dist/auto-doc.js +5 -5
- package/dist/auto-escalate/index.d.ts +43 -0
- package/dist/auto-escalate/index.d.ts.map +1 -0
- package/dist/auto-escalate.d.ts +2 -45
- package/dist/auto-escalate.js +5 -2
- package/dist/auto-i18n-extractor/index.d.ts +34 -0
- package/dist/auto-i18n-extractor/index.d.ts.map +1 -0
- package/dist/auto-i18n-extractor.d.ts +2 -36
- package/dist/auto-i18n-extractor.js +6 -7
- package/dist/branch-guard/index.d.ts +32 -0
- package/dist/branch-guard/index.d.ts.map +1 -0
- package/dist/branch-guard.d.ts +2 -34
- package/dist/branch-guard.js +4 -4
- package/dist/catalog.d.ts +39 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/changelog-writer/index.d.ts +71 -0
- package/dist/changelog-writer/index.d.ts.map +1 -0
- package/dist/changelog-writer.d.ts +2 -73
- package/dist/changelog-writer.js +9 -5
- package/dist/checkpoint/index.d.ts +53 -0
- package/dist/checkpoint/index.d.ts.map +1 -0
- package/dist/checkpoint.d.ts +2 -55
- package/dist/checkpoint.js +6 -6
- package/dist/code-metrics/index.d.ts +29 -0
- package/dist/code-metrics/index.d.ts.map +1 -0
- package/dist/code-metrics.d.ts +2 -31
- package/dist/code-metrics.js +13 -15
- package/dist/commit-validator/index.d.ts +31 -0
- package/dist/commit-validator/index.d.ts.map +1 -0
- package/dist/commit-validator.d.ts +2 -33
- package/dist/commit-validator.js +5 -3
- package/dist/config-validator/index.d.ts +46 -0
- package/dist/config-validator/index.d.ts.map +1 -0
- package/dist/config-validator.d.ts +2 -48
- package/dist/config-validator.js +8 -4
- package/dist/context-pins/index.d.ts +43 -0
- package/dist/context-pins/index.d.ts.map +1 -0
- package/dist/context-pins.d.ts +2 -45
- package/dist/context-pins.js +5 -5
- package/dist/cost-tracker/index.d.ts +51 -0
- package/dist/cost-tracker/index.d.ts.map +1 -0
- package/dist/cost-tracker.d.ts +2 -53
- package/dist/cost-tracker.js +4 -4
- package/dist/cron/index.d.ts +12 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/cron.d.ts +2 -14
- package/dist/cron.js +3 -2
- package/dist/dead-code-detector/index.d.ts +32 -0
- package/dist/dead-code-detector/index.d.ts.map +1 -0
- package/dist/dead-code-detector.d.ts +2 -34
- package/dist/dead-code-detector.js +8 -9
- package/dist/dep-guard/index.d.ts +63 -0
- package/dist/dep-guard/index.d.ts.map +1 -0
- package/dist/dep-guard.d.ts +2 -65
- package/dist/dep-guard.js +6 -2
- package/dist/dependency-vulnerability-gate/index.d.ts +33 -0
- package/dist/dependency-vulnerability-gate/index.d.ts.map +1 -0
- package/dist/dependency-vulnerability-gate.d.ts +2 -35
- package/dist/dependency-vulnerability-gate.js +5 -5
- package/dist/diff-summary/index.d.ts +34 -0
- package/dist/diff-summary/index.d.ts.map +1 -0
- package/dist/diff-summary.d.ts +2 -36
- package/dist/diff-summary.js +5 -5
- package/dist/doc-sync-guard/index.d.ts +31 -0
- package/dist/doc-sync-guard/index.d.ts.map +1 -0
- package/dist/doc-sync-guard.d.ts +2 -33
- package/dist/doc-sync-guard.js +4 -4
- package/dist/duplicate-code-detector/index.d.ts +31 -0
- package/dist/duplicate-code-detector/index.d.ts.map +1 -0
- package/dist/duplicate-code-detector.d.ts +2 -33
- package/dist/duplicate-code-detector.js +5 -5
- package/dist/error-lens/index.d.ts +65 -0
- package/dist/error-lens/index.d.ts.map +1 -0
- package/dist/error-lens.d.ts +2 -67
- package/dist/error-lens.js +5 -2
- package/dist/feature-flag-tracker/index.d.ts +36 -0
- package/dist/feature-flag-tracker/index.d.ts.map +1 -0
- package/dist/feature-flag-tracker.d.ts +2 -38
- package/dist/feature-flag-tracker.js +6 -7
- package/dist/file-watcher/index.d.ts +12 -0
- package/dist/file-watcher/index.d.ts.map +1 -0
- package/dist/file-watcher.d.ts +2 -14
- package/dist/file-watcher.js +7 -7
- package/dist/format-on-save/index.d.ts +33 -0
- package/dist/format-on-save/index.d.ts.map +1 -0
- package/dist/format-on-save.d.ts +2 -35
- package/dist/format-on-save.js +6 -6
- package/dist/git-autocommit/index.d.ts +15 -0
- package/dist/git-autocommit/index.d.ts.map +1 -0
- package/dist/git-autocommit.d.ts +2 -17
- package/dist/git-autocommit.js +5 -5
- package/dist/import-organizer/index.d.ts +50 -0
- package/dist/import-organizer/index.d.ts.map +1 -0
- package/dist/import-organizer.d.ts +2 -52
- package/dist/import-organizer.js +6 -6
- package/dist/index.d.ts +186 -64
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +992 -454
- package/dist/injection-shield/index.d.ts +47 -0
- package/dist/injection-shield/index.d.ts.map +1 -0
- package/dist/injection-shield.d.ts +2 -49
- package/dist/injection-shield.js +4 -2
- package/dist/interface-contract-guard/index.d.ts +35 -0
- package/dist/interface-contract-guard/index.d.ts.map +1 -0
- package/dist/interface-contract-guard.d.ts +2 -37
- package/dist/interface-contract-guard.js +6 -7
- package/dist/knowledge-graph/index.d.ts +43 -0
- package/dist/knowledge-graph/index.d.ts.map +1 -0
- package/dist/knowledge-graph.d.ts +2 -45
- package/dist/knowledge-graph.js +5 -5
- package/dist/license-audit-gate/index.d.ts +32 -0
- package/dist/license-audit-gate/index.d.ts.map +1 -0
- package/dist/license-audit-gate.d.ts +2 -34
- package/dist/license-audit-gate.js +6 -7
- package/dist/lint-gate/index.d.ts +31 -0
- package/dist/lint-gate/index.d.ts.map +1 -0
- package/dist/lint-gate.d.ts +2 -33
- package/dist/lint-gate.js +7 -7
- package/dist/llm-cache/index.d.ts +54 -0
- package/dist/llm-cache/index.d.ts.map +1 -0
- package/dist/llm-cache.d.ts +2 -56
- package/dist/llm-cache.js +6 -4
- package/dist/loop-breaker/index.d.ts +4 -0
- package/dist/loop-breaker/index.d.ts.map +1 -0
- package/dist/loop-breaker.d.ts +2 -5
- package/dist/loop-breaker.js +4 -4
- package/dist/migration-planner/index.d.ts +28 -0
- package/dist/migration-planner/index.d.ts.map +1 -0
- package/dist/migration-planner.d.ts +2 -30
- package/dist/migration-planner.js +5 -5
- package/dist/model-router/index.d.ts +67 -0
- package/dist/model-router/index.d.ts.map +1 -0
- package/dist/model-router.d.ts +2 -69
- package/dist/model-router.js +5 -2
- package/dist/notify-hub/index.d.ts +43 -0
- package/dist/notify-hub/index.d.ts.map +1 -0
- package/dist/notify-hub.d.ts +2 -45
- package/dist/notify-hub.js +3 -2
- package/dist/path-guard/index.d.ts +52 -0
- package/dist/path-guard/index.d.ts.map +1 -0
- package/dist/path-guard.d.ts +2 -54
- package/dist/path-guard.js +5 -2
- package/dist/performance-regression-gate/index.d.ts +31 -0
- package/dist/performance-regression-gate/index.d.ts.map +1 -0
- package/dist/performance-regression-gate.d.ts +2 -33
- package/dist/performance-regression-gate.js +5 -5
- package/dist/plugin-stack-observer/index.d.ts +33 -0
- package/dist/plugin-stack-observer/index.d.ts.map +1 -0
- package/dist/plugin-stack-observer.d.ts +2 -35
- package/dist/plugin-stack-observer.js +3 -2
- package/dist/pr-drafter/index.d.ts +33 -0
- package/dist/pr-drafter/index.d.ts.map +1 -0
- package/dist/pr-drafter.d.ts +2 -35
- package/dist/pr-drafter.js +6 -6
- package/dist/prompt-firewall/index.d.ts +55 -0
- package/dist/prompt-firewall/index.d.ts.map +1 -0
- package/dist/prompt-firewall.d.ts +2 -57
- package/dist/prompt-firewall.js +5 -2
- package/dist/refactor-suggester/index.d.ts +36 -0
- package/dist/refactor-suggester/index.d.ts.map +1 -0
- package/dist/refactor-suggester.d.ts +2 -38
- package/dist/refactor-suggester.js +16 -17
- package/dist/release-notes-generator/index.d.ts +25 -0
- package/dist/release-notes-generator/index.d.ts.map +1 -0
- package/dist/release-notes-generator.d.ts +2 -27
- package/dist/release-notes-generator.js +28 -10
- package/dist/runtime/index.d.ts +124 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +216 -0
- package/dist/schema-evolution-guard/index.d.ts +40 -0
- package/dist/schema-evolution-guard/index.d.ts.map +1 -0
- package/dist/schema-evolution-guard.d.ts +2 -42
- package/dist/schema-evolution-guard.js +5 -5
- package/dist/secret-scanner/index.d.ts +32 -0
- package/dist/secret-scanner/index.d.ts.map +1 -0
- package/dist/secret-scanner.d.ts +2 -34
- package/dist/secret-scanner.js +3 -2
- package/dist/security-hotspot-scanner/index.d.ts +28 -0
- package/dist/security-hotspot-scanner/index.d.ts.map +1 -0
- package/dist/security-hotspot-scanner.d.ts +2 -30
- package/dist/security-hotspot-scanner.js +6 -6
- package/dist/semantic-search-indexer/index.d.ts +36 -0
- package/dist/semantic-search-indexer/index.d.ts.map +1 -0
- package/dist/semantic-search-indexer.d.ts +2 -38
- package/dist/semantic-search-indexer.js +22 -6
- package/dist/semver-bump/index.d.ts +24 -0
- package/dist/semver-bump/index.d.ts.map +1 -0
- package/dist/semver-bump.d.ts +2 -26
- package/dist/semver-bump.js +10 -8
- package/dist/session-recap/index.d.ts +48 -0
- package/dist/session-recap/index.d.ts.map +1 -0
- package/dist/session-recap.d.ts +2 -50
- package/dist/session-recap.js +6 -4
- package/dist/shell-check/index.d.ts +14 -0
- package/dist/shell-check/index.d.ts.map +1 -0
- package/dist/shell-check.d.ts +2 -16
- package/dist/shell-check.js +6 -6
- package/dist/smart-rename/index.d.ts +24 -0
- package/dist/smart-rename/index.d.ts.map +1 -0
- package/dist/smart-rename.d.ts +2 -26
- package/dist/smart-rename.js +5 -5
- package/dist/spec-linker/index.d.ts +49 -0
- package/dist/spec-linker/index.d.ts.map +1 -0
- package/dist/spec-linker.d.ts +2 -51
- package/dist/spec-linker.js +20086 -244
- package/dist/template-engine/index.d.ts +13 -0
- package/dist/template-engine/index.d.ts.map +1 -0
- package/dist/template-engine.d.ts +2 -15
- package/dist/template-engine.js +7 -7
- package/dist/test-coverage-gate/index.d.ts +35 -0
- package/dist/test-coverage-gate/index.d.ts.map +1 -0
- package/dist/test-coverage-gate.d.ts +2 -37
- package/dist/test-coverage-gate.js +5 -5
- package/dist/test-flake-detector/index.d.ts +25 -0
- package/dist/test-flake-detector/index.d.ts.map +1 -0
- package/dist/test-flake-detector.d.ts +2 -27
- package/dist/test-flake-detector.js +98 -13
- package/dist/test-generator/index.d.ts +30 -0
- package/dist/test-generator/index.d.ts.map +1 -0
- package/dist/test-generator.d.ts +2 -32
- package/dist/test-generator.js +19 -20
- package/dist/test-runner-gate/index.d.ts +35 -0
- package/dist/test-runner-gate/index.d.ts.map +1 -0
- package/dist/test-runner-gate.d.ts +2 -37
- package/dist/test-runner-gate.js +6 -6
- package/dist/todo-listener/index.d.ts +35 -0
- package/dist/todo-listener/index.d.ts.map +1 -0
- package/dist/todo-listener.d.ts +2 -37
- package/dist/todo-listener.js +3 -2
- package/dist/todo-tracker/index.d.ts +4 -0
- package/dist/todo-tracker/index.d.ts.map +1 -0
- package/dist/todo-tracker.d.ts +2 -5
- package/dist/todo-tracker.js +5 -5
- package/dist/token-budget/index.d.ts +38 -0
- package/dist/token-budget/index.d.ts.map +1 -0
- package/dist/token-budget.d.ts +2 -40
- package/dist/token-budget.js +3 -2
- package/dist/token-throttle/index.d.ts +52 -0
- package/dist/token-throttle/index.d.ts.map +1 -0
- package/dist/token-throttle.d.ts +2 -54
- package/dist/token-throttle.js +6 -2
- package/dist/type-gate/index.d.ts +35 -0
- package/dist/type-gate/index.d.ts.map +1 -0
- package/dist/type-gate.d.ts +2 -37
- package/dist/type-gate.js +236 -43
- package/package.json +10 -7
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* auto-i18n-extractor plugin — detects hardcoded user-facing strings in UI
|
|
5
|
-
* source files and suggests translation keys.
|
|
6
|
-
*
|
|
7
|
-
* Tools registered:
|
|
8
|
-
* - i18n_extract : Scan a file/directory path for extractable strings.
|
|
9
|
-
* - i18n_status : Show config + per-session counters.
|
|
10
|
-
*
|
|
11
|
-
* Hooks registered:
|
|
12
|
-
* - PostToolUse with matcher `write|edit` for `.tsx`, `.jsx`, `.vue` files.
|
|
13
|
-
* Scans the written file and injects a short additionalContext with
|
|
14
|
-
* suggested i18n keys when user-facing string literals are found.
|
|
15
|
-
*
|
|
16
|
-
* Config (`config.extensions['auto-i18n-extractor']`):
|
|
17
|
-
*
|
|
18
|
-
* ```jsonc
|
|
19
|
-
* {
|
|
20
|
-
* "enabled": true,
|
|
21
|
-
* "fileExtensions": [".tsx", ".jsx", ".vue"],
|
|
22
|
-
* "minLength": 2,
|
|
23
|
-
* "maxContextStrings": 10,
|
|
24
|
-
* "excludeAttributes": [
|
|
25
|
-
* "className", "class", "testId", "data-testid",
|
|
26
|
-
* "aria-label", "aria-labelledby", "key", "id", "name", "htmlFor"
|
|
27
|
-
* ]
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
declare const plugin: Plugin;
|
|
35
|
-
|
|
36
|
-
export { plugin as default };
|
|
1
|
+
export * from './auto-i18n-extractor/index.js';
|
|
2
|
+
export { default } from './auto-i18n-extractor/index.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { readFileSync } from 'fs';
|
|
2
|
-
import { isAbsolute, resolve, relative } from 'path';
|
|
3
|
-
|
|
4
1
|
// src/auto-i18n-extractor/index.ts
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
5
4
|
var API_VERSION = "^0.1.10";
|
|
6
5
|
var state = {
|
|
7
6
|
filesScanned: 0,
|
|
@@ -84,8 +83,7 @@ function extractStrings(content, cfg) {
|
|
|
84
83
|
for (let i = 0; i < lines.length; i += 1) {
|
|
85
84
|
const line = lines[i];
|
|
86
85
|
stringRegex.lastIndex = 0;
|
|
87
|
-
|
|
88
|
-
while ((match = stringRegex.exec(line)) !== null) {
|
|
86
|
+
for (const match of line.matchAll(stringRegex)) {
|
|
89
87
|
const value = match[2] ?? "";
|
|
90
88
|
const quoteIndex = match.index + (match[1]?.length ?? 1);
|
|
91
89
|
if (!looksLikeUserText(value, cfg.minLength)) continue;
|
|
@@ -331,5 +329,6 @@ ${lines.join("\n")}${more}`;
|
|
|
331
329
|
}
|
|
332
330
|
};
|
|
333
331
|
var auto_i18n_extractor_default = plugin;
|
|
334
|
-
|
|
335
|
-
|
|
332
|
+
export {
|
|
333
|
+
auto_i18n_extractor_default as default
|
|
334
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* branch-guard plugin — PreToolUse hook that blocks commits, pushes,
|
|
3
|
+
* and merges to protected branches (default: main, master).
|
|
4
|
+
*
|
|
5
|
+
* Tools registered:
|
|
6
|
+
* - branch_guard_status : Show protected branches, mode, and counters.
|
|
7
|
+
*
|
|
8
|
+
* Hooks registered:
|
|
9
|
+
* - PreToolUse with matcher `bash|git|git_autocommit`. Inspects the tool
|
|
10
|
+
* input for git commit / push / merge commands (bash), structured git
|
|
11
|
+
* operations (git), or the tool call itself (git_autocommit). If the current
|
|
12
|
+
* branch is protected, the call is blocked with a clear reason.
|
|
13
|
+
*
|
|
14
|
+
* Config (`config.extensions['branch-guard']`):
|
|
15
|
+
*
|
|
16
|
+
* ```jsonc
|
|
17
|
+
* {
|
|
18
|
+
* "enabled": true, // set false to make the hook a no-op
|
|
19
|
+
* "branches": ["main", "master"], // protected branch names
|
|
20
|
+
* "mode": "block", // "block" | "warn" | "off"
|
|
21
|
+
* "blockMerge": true, // also block merges into protected
|
|
22
|
+
* "blockPush": true, // also block pushes from protected
|
|
23
|
+
* "blockCommit": true // also block commits on protected
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
import type { Plugin } from '@wrongstack/core';
|
|
30
|
+
declare const plugin: Plugin;
|
|
31
|
+
export default plugin;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/branch-guard/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAuM/C,QAAA,MAAM,MAAM,EAAE,MAoPb,CAAC;eAEa,MAAM"}
|
package/dist/branch-guard.d.ts
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* branch-guard plugin — PreToolUse hook that blocks commits, pushes,
|
|
5
|
-
* and merges to protected branches (default: main, master).
|
|
6
|
-
*
|
|
7
|
-
* Tools registered:
|
|
8
|
-
* - branch_guard_status : Show protected branches, mode, and counters.
|
|
9
|
-
*
|
|
10
|
-
* Hooks registered:
|
|
11
|
-
* - PreToolUse with matcher `bash|git|git_autocommit`. Inspects the tool
|
|
12
|
-
* input for git commit / push / merge commands (bash), structured git
|
|
13
|
-
* operations (git), or the tool call itself (git_autocommit). If the current
|
|
14
|
-
* branch is protected, the call is blocked with a clear reason.
|
|
15
|
-
*
|
|
16
|
-
* Config (`config.extensions['branch-guard']`):
|
|
17
|
-
*
|
|
18
|
-
* ```jsonc
|
|
19
|
-
* {
|
|
20
|
-
* "enabled": true, // set false to make the hook a no-op
|
|
21
|
-
* "branches": ["main", "master"], // protected branch names
|
|
22
|
-
* "mode": "block", // "block" | "warn" | "off"
|
|
23
|
-
* "blockMerge": true, // also block merges into protected
|
|
24
|
-
* "blockPush": true, // also block pushes from protected
|
|
25
|
-
* "blockCommit": true // also block commits on protected
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
declare const plugin: Plugin;
|
|
33
|
-
|
|
34
|
-
export { plugin as default };
|
|
1
|
+
export * from './branch-guard/index.js';
|
|
2
|
+
export { default } from './branch-guard/index.js';
|
package/dist/branch-guard.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { execFile } from 'child_process';
|
|
2
|
-
|
|
3
1
|
// src/branch-guard/index.ts
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
4
3
|
var API_VERSION = "^0.1.10";
|
|
5
4
|
var state = {
|
|
6
5
|
invocationCount: 0,
|
|
@@ -299,5 +298,6 @@ var plugin = {
|
|
|
299
298
|
}
|
|
300
299
|
};
|
|
301
300
|
var branch_guard_default = plugin;
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
export {
|
|
302
|
+
branch_guard_default as default
|
|
303
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin catalog — single source of truth for plugin names and their
|
|
3
|
+
* canonical source paths. Used by `spec-linker` to detect unlinked
|
|
4
|
+
* plugin references in markdown files.
|
|
5
|
+
*
|
|
6
|
+
* The catalog is built at module load time by importing each plugin
|
|
7
|
+
* source and reading its `name` field. This means the catalog is
|
|
8
|
+
* always in sync with the actual plugins — adding a new plugin
|
|
9
|
+
* (exporting it from `./index.ts` AND adding a row to the table
|
|
10
|
+
* below) is enough for `spec-linker` to start detecting references
|
|
11
|
+
* to it.
|
|
12
|
+
*
|
|
13
|
+
* To add a new plugin: see the table in `catalog.ts`. The `name`
|
|
14
|
+
* must match the plugin's `name` field; the `path` is the
|
|
15
|
+
* relative source directory under `packages/plugins/src/`.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
import type { Plugin } from '@wrongstack/core';
|
|
20
|
+
interface CatalogEntry {
|
|
21
|
+
/** The plugin's `name` field. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Relative path under `packages/plugins/src/`, e.g. `./src/auto-doc`. */
|
|
24
|
+
path: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read-only view of the catalog as a Map from plugin name to its
|
|
28
|
+
* source path. Frozen so consumers cannot mutate it.
|
|
29
|
+
*/
|
|
30
|
+
export declare const PLUGIN_CATALOG: ReadonlyMap<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* The list of catalog entries, ordered by the table above. Used by
|
|
33
|
+
* `spec-linker` to iterate names in a stable order for detection.
|
|
34
|
+
*/
|
|
35
|
+
export declare const PLUGIN_CATALOG_ENTRIES: readonly CatalogEntry[];
|
|
36
|
+
/** Convenience accessor: just the names, in declaration order. */
|
|
37
|
+
export declare const PLUGIN_NAMES: readonly string[];
|
|
38
|
+
export type { Plugin };
|
|
39
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAuE/C,UAAU,YAAY;IACpB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;CACd;AA+FD;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAInD,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,YAAY,EAEzD,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAA8C,CAAC;AAIzF,YAAY,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* changelog-writer plugin — turns session activity into
|
|
3
|
+
* Keep-a-Changelog entries.
|
|
4
|
+
*
|
|
5
|
+
* While the session runs, the plugin passively collects work signals
|
|
6
|
+
* from the event bus: files touched by `write`/`edit`, and commit
|
|
7
|
+
* subjects observed from `git_autocommit` / `bash git commit`
|
|
8
|
+
* invocations. Commit subjects in conventional-commit format are
|
|
9
|
+
* mapped to Keep-a-Changelog sections:
|
|
10
|
+
*
|
|
11
|
+
* feat → Added · fix → Fixed · perf/refactor → Changed ·
|
|
12
|
+
* docs → Documentation · chore/build/ci → Maintenance ·
|
|
13
|
+
* revert/remove → Removed · sec/security → Security
|
|
14
|
+
*
|
|
15
|
+
* Tools:
|
|
16
|
+
* - `changelog_add` — record an entry manually ("Added dark mode")
|
|
17
|
+
* - `changelog_preview` — render the pending Unreleased block
|
|
18
|
+
* - `changelog_write` — merge the pending entries into
|
|
19
|
+
* `CHANGELOG.md` under `## [Unreleased]` (creates the file with a
|
|
20
|
+
* Keep-a-Changelog header when missing); pending entries are
|
|
21
|
+
* cleared after a successful write
|
|
22
|
+
*
|
|
23
|
+
* Both `changelog_preview` and `changelog_write` accept `polish: true`
|
|
24
|
+
* to rewrite the block into user-facing release-notes wording via the
|
|
25
|
+
* host LLM (`api.llm`) — provider/model follow the plugin's
|
|
26
|
+
* `config.extensions['changelog-writer'].llm` override, then the
|
|
27
|
+
* session default. Polish is best-effort: on any LLM failure (or when
|
|
28
|
+
* the response stops looking like the block) the raw entries are used.
|
|
29
|
+
*
|
|
30
|
+
* Config (`config.extensions['changelog-writer']`):
|
|
31
|
+
*
|
|
32
|
+
* ```jsonc
|
|
33
|
+
* {
|
|
34
|
+
* "enabled": true,
|
|
35
|
+
* "filePath": "CHANGELOG.md",
|
|
36
|
+
* "collectCommits": true,
|
|
37
|
+
* "maxEntries": 200
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Toggle off with `{ "name": "changelog-writer", "enabled": false }`
|
|
42
|
+
* in `config.plugins`, or `"enabled": false` in the options above.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
import type { Plugin } from '@wrongstack/core';
|
|
47
|
+
type Section = 'Added' | 'Changed' | 'Fixed' | 'Removed' | 'Security' | 'Documentation' | 'Maintenance';
|
|
48
|
+
export interface ChangelogEntry {
|
|
49
|
+
section: Section;
|
|
50
|
+
text: string;
|
|
51
|
+
origin: 'commit' | 'manual';
|
|
52
|
+
when: string;
|
|
53
|
+
}
|
|
54
|
+
/** Parse "feat(scope): add dark mode" → { section: Added, text: "add dark mode (scope)" }. */
|
|
55
|
+
export declare function commitToEntry(subject: string): {
|
|
56
|
+
section: Section;
|
|
57
|
+
text: string;
|
|
58
|
+
};
|
|
59
|
+
/** Extract the commit subject from a `git commit -m "..."` command, if any. */
|
|
60
|
+
export declare function commitSubjectFromCommand(command: string): string | null;
|
|
61
|
+
export declare function renderUnreleasedBlock(entries: ChangelogEntry[]): string;
|
|
62
|
+
/**
|
|
63
|
+
* Merge a rendered Unreleased block into existing changelog content:
|
|
64
|
+
* inserted directly under `## [Unreleased]` (existing unreleased
|
|
65
|
+
* content is preserved below the new lines). Creates the standard
|
|
66
|
+
* header when the file has no Unreleased heading.
|
|
67
|
+
*/
|
|
68
|
+
export declare function mergeIntoChangelog(existing: string | null, block: string): string;
|
|
69
|
+
declare const plugin: Plugin;
|
|
70
|
+
export default plugin;
|
|
71
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/changelog-writer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM/C,KAAK,OAAO,GACR,OAAO,GACP,SAAS,GACT,OAAO,GACP,SAAS,GACT,UAAU,GACV,eAAe,GACf,aAAa,CAAC;AAElB,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAmGD,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAQjF;AAED,+EAA+E;AAC/E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOvE;AAeD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,CAiBvE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAiBjF;AAMD,QAAA,MAAM,MAAM,EAAE,MAqRb,CAAC;eAEa,MAAM"}
|
|
@@ -1,73 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* changelog-writer plugin — turns session activity into
|
|
5
|
-
* Keep-a-Changelog entries.
|
|
6
|
-
*
|
|
7
|
-
* While the session runs, the plugin passively collects work signals
|
|
8
|
-
* from the event bus: files touched by `write`/`edit`, and commit
|
|
9
|
-
* subjects observed from `git_autocommit` / `bash git commit`
|
|
10
|
-
* invocations. Commit subjects in conventional-commit format are
|
|
11
|
-
* mapped to Keep-a-Changelog sections:
|
|
12
|
-
*
|
|
13
|
-
* feat → Added · fix → Fixed · perf/refactor → Changed ·
|
|
14
|
-
* docs → Documentation · chore/build/ci → Maintenance ·
|
|
15
|
-
* revert/remove → Removed · sec/security → Security
|
|
16
|
-
*
|
|
17
|
-
* Tools:
|
|
18
|
-
* - `changelog_add` — record an entry manually ("Added dark mode")
|
|
19
|
-
* - `changelog_preview` — render the pending Unreleased block
|
|
20
|
-
* - `changelog_write` — merge the pending entries into
|
|
21
|
-
* `CHANGELOG.md` under `## [Unreleased]` (creates the file with a
|
|
22
|
-
* Keep-a-Changelog header when missing); pending entries are
|
|
23
|
-
* cleared after a successful write
|
|
24
|
-
*
|
|
25
|
-
* Both `changelog_preview` and `changelog_write` accept `polish: true`
|
|
26
|
-
* to rewrite the block into user-facing release-notes wording via the
|
|
27
|
-
* host LLM (`api.llm`) — provider/model follow the plugin's
|
|
28
|
-
* `config.extensions['changelog-writer'].llm` override, then the
|
|
29
|
-
* session default. Polish is best-effort: on any LLM failure (or when
|
|
30
|
-
* the response stops looking like the block) the raw entries are used.
|
|
31
|
-
*
|
|
32
|
-
* Config (`config.extensions['changelog-writer']`):
|
|
33
|
-
*
|
|
34
|
-
* ```jsonc
|
|
35
|
-
* {
|
|
36
|
-
* "enabled": true,
|
|
37
|
-
* "filePath": "CHANGELOG.md",
|
|
38
|
-
* "collectCommits": true,
|
|
39
|
-
* "maxEntries": 200
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* Toggle off with `{ "name": "changelog-writer", "enabled": false }`
|
|
44
|
-
* in `config.plugins`, or `"enabled": false` in the options above.
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
type Section = 'Added' | 'Changed' | 'Fixed' | 'Removed' | 'Security' | 'Documentation' | 'Maintenance';
|
|
50
|
-
interface ChangelogEntry {
|
|
51
|
-
section: Section;
|
|
52
|
-
text: string;
|
|
53
|
-
origin: 'commit' | 'manual';
|
|
54
|
-
when: string;
|
|
55
|
-
}
|
|
56
|
-
/** Parse "feat(scope): add dark mode" → { section: Added, text: "add dark mode (scope)" }. */
|
|
57
|
-
declare function commitToEntry(subject: string): {
|
|
58
|
-
section: Section;
|
|
59
|
-
text: string;
|
|
60
|
-
};
|
|
61
|
-
/** Extract the commit subject from a `git commit -m "..."` command, if any. */
|
|
62
|
-
declare function commitSubjectFromCommand(command: string): string | null;
|
|
63
|
-
declare function renderUnreleasedBlock(entries: ChangelogEntry[]): string;
|
|
64
|
-
/**
|
|
65
|
-
* Merge a rendered Unreleased block into existing changelog content:
|
|
66
|
-
* inserted directly under `## [Unreleased]` (existing unreleased
|
|
67
|
-
* content is preserved below the new lines). Creates the standard
|
|
68
|
-
* header when the file has no Unreleased heading.
|
|
69
|
-
*/
|
|
70
|
-
declare function mergeIntoChangelog(existing: string | null, block: string): string;
|
|
71
|
-
declare const plugin: Plugin;
|
|
72
|
-
|
|
73
|
-
export { type ChangelogEntry, commitSubjectFromCommand, commitToEntry, plugin as default, mergeIntoChangelog, renderUnreleasedBlock };
|
|
1
|
+
export * from './changelog-writer/index.js';
|
|
2
|
+
export { default } from './changelog-writer/index.js';
|
package/dist/changelog-writer.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
2
|
-
import { resolve, isAbsolute, relative } from 'path';
|
|
3
|
-
|
|
4
1
|
// src/changelog-writer/index.ts
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
5
4
|
var state = {
|
|
6
5
|
entries: [],
|
|
7
6
|
filesTouched: /* @__PURE__ */ new Set(),
|
|
@@ -376,5 +375,10 @@ var plugin = {
|
|
|
376
375
|
}
|
|
377
376
|
};
|
|
378
377
|
var changelog_writer_default = plugin;
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
export {
|
|
379
|
+
commitSubjectFromCommand,
|
|
380
|
+
commitToEntry,
|
|
381
|
+
changelog_writer_default as default,
|
|
382
|
+
mergeIntoChangelog,
|
|
383
|
+
renderUnreleasedBlock
|
|
384
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* checkpoint plugin — in-session file snapshots with one-call undo.
|
|
3
|
+
*
|
|
4
|
+
* Before every `write`/`edit` the plugin captures the file's current
|
|
5
|
+
* content (a `PreToolUse` hook reads the file from disk *before* the
|
|
6
|
+
* tool mutates it). Snapshots are held in an in-memory ring, so the
|
|
7
|
+
* agent can always roll back a bad edit — even one made outside git
|
|
8
|
+
* (untracked files, mid-refactor states, dirty worktrees).
|
|
9
|
+
*
|
|
10
|
+
* Tools:
|
|
11
|
+
* - `checkpoint_list` — list captured snapshots (newest first)
|
|
12
|
+
* - `checkpoint_restore` — restore a file (or all files of a
|
|
13
|
+
* checkpoint) to its captured content; files that did not exist
|
|
14
|
+
* at capture time are noted, never deleted
|
|
15
|
+
* - `checkpoint_create` — manually snapshot a list of files before
|
|
16
|
+
* a risky operation (bulk rename, codemod, script run)
|
|
17
|
+
*
|
|
18
|
+
* This deliberately complements git: `git checkout` needs a commit
|
|
19
|
+
* to restore to; checkpoint restores to *any* pre-edit state from
|
|
20
|
+
* this session, including states that were never committed.
|
|
21
|
+
*
|
|
22
|
+
* Config (`config.extensions['checkpoint']`):
|
|
23
|
+
*
|
|
24
|
+
* ```jsonc
|
|
25
|
+
* {
|
|
26
|
+
* "enabled": true,
|
|
27
|
+
* "autoCapture": true, // snapshot before every write/edit
|
|
28
|
+
* "maxSnapshots": 50, // ring size
|
|
29
|
+
* "maxFileBytes": 1048576 // skip files larger than this (1 MiB)
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Toggle off with `{ "name": "checkpoint", "enabled": false }` in
|
|
34
|
+
* `config.plugins`, or `"enabled": false` in the options above.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
import type { Plugin } from '@wrongstack/core';
|
|
39
|
+
export interface Snapshot {
|
|
40
|
+
id: string;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
/** What triggered the capture: 'auto:write', 'auto:edit', or 'manual'. */
|
|
43
|
+
origin: string;
|
|
44
|
+
files: Array<{
|
|
45
|
+
path: string;
|
|
46
|
+
/** null = file did not exist at capture time. */
|
|
47
|
+
content: string | null;
|
|
48
|
+
bytes: number;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
declare const plugin: Plugin;
|
|
52
|
+
export default plugin;
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/checkpoint/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM/C,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,iDAAiD;QACjD,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AA+HD,QAAA,MAAM,MAAM,EAAE,MAwUb,CAAC;eAEa,MAAM"}
|
package/dist/checkpoint.d.ts
CHANGED
|
@@ -1,55 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* checkpoint plugin — in-session file snapshots with one-call undo.
|
|
5
|
-
*
|
|
6
|
-
* Before every `write`/`edit` the plugin captures the file's current
|
|
7
|
-
* content (a `PreToolUse` hook reads the file from disk *before* the
|
|
8
|
-
* tool mutates it). Snapshots are held in an in-memory ring, so the
|
|
9
|
-
* agent can always roll back a bad edit — even one made outside git
|
|
10
|
-
* (untracked files, mid-refactor states, dirty worktrees).
|
|
11
|
-
*
|
|
12
|
-
* Tools:
|
|
13
|
-
* - `checkpoint_list` — list captured snapshots (newest first)
|
|
14
|
-
* - `checkpoint_restore` — restore a file (or all files of a
|
|
15
|
-
* checkpoint) to its captured content; files that did not exist
|
|
16
|
-
* at capture time are noted, never deleted
|
|
17
|
-
* - `checkpoint_create` — manually snapshot a list of files before
|
|
18
|
-
* a risky operation (bulk rename, codemod, script run)
|
|
19
|
-
*
|
|
20
|
-
* This deliberately complements git: `git checkout` needs a commit
|
|
21
|
-
* to restore to; checkpoint restores to *any* pre-edit state from
|
|
22
|
-
* this session, including states that were never committed.
|
|
23
|
-
*
|
|
24
|
-
* Config (`config.extensions['checkpoint']`):
|
|
25
|
-
*
|
|
26
|
-
* ```jsonc
|
|
27
|
-
* {
|
|
28
|
-
* "enabled": true,
|
|
29
|
-
* "autoCapture": true, // snapshot before every write/edit
|
|
30
|
-
* "maxSnapshots": 50, // ring size
|
|
31
|
-
* "maxFileBytes": 1048576 // skip files larger than this (1 MiB)
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* Toggle off with `{ "name": "checkpoint", "enabled": false }` in
|
|
36
|
-
* `config.plugins`, or `"enabled": false` in the options above.
|
|
37
|
-
*
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
interface Snapshot {
|
|
42
|
-
id: string;
|
|
43
|
-
createdAt: string;
|
|
44
|
-
/** What triggered the capture: 'auto:write', 'auto:edit', or 'manual'. */
|
|
45
|
-
origin: string;
|
|
46
|
-
files: Array<{
|
|
47
|
-
path: string;
|
|
48
|
-
/** null = file did not exist at capture time. */
|
|
49
|
-
content: string | null;
|
|
50
|
-
bytes: number;
|
|
51
|
-
}>;
|
|
52
|
-
}
|
|
53
|
-
declare const plugin: Plugin;
|
|
54
|
-
|
|
55
|
-
export { type Snapshot, plugin as default };
|
|
1
|
+
export * from './checkpoint/index.js';
|
|
2
|
+
export { default } from './checkpoint/index.js';
|
package/dist/checkpoint.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync, statSync, readFileSync } from 'fs';
|
|
2
|
-
import { stat, readFile } from 'fs/promises';
|
|
3
|
-
import { dirname, resolve, isAbsolute, relative } from 'path';
|
|
4
|
-
|
|
5
1
|
// src/checkpoint/index.ts
|
|
2
|
+
import { mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { readFile, stat } from "node:fs/promises";
|
|
4
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
6
5
|
var state = {
|
|
7
6
|
snapshots: [],
|
|
8
7
|
nextId: 1,
|
|
@@ -361,5 +360,6 @@ var plugin = {
|
|
|
361
360
|
}
|
|
362
361
|
};
|
|
363
362
|
var checkpoint_default = plugin;
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
export {
|
|
364
|
+
checkpoint_default as default
|
|
365
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* code-metrics plugin — lightweight per-file code metrics using regex-based
|
|
3
|
+
* line counting and complexity heuristics.
|
|
4
|
+
*
|
|
5
|
+
* Tools registered:
|
|
6
|
+
* - measure_code_metrics : Compute lines, comments, blanks, function count,
|
|
7
|
+
* and cyclomatic-complexity-like score for a file or directory.
|
|
8
|
+
* - metrics_status : Report config + counters.
|
|
9
|
+
*
|
|
10
|
+
* Hooks registered:
|
|
11
|
+
* - PostToolUse with matcher `write|edit` to source files, injecting a
|
|
12
|
+
* one-line metric summary of the changed file.
|
|
13
|
+
*
|
|
14
|
+
* Config (`config.extensions['code-metrics']`):
|
|
15
|
+
*
|
|
16
|
+
* ```jsonc
|
|
17
|
+
* {
|
|
18
|
+
* "enabled": true,
|
|
19
|
+
* "extensions": [".ts", ".tsx", ".js", ".jsx"],
|
|
20
|
+
* "maxFiles": 50
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
import type { Plugin } from '@wrongstack/core';
|
|
27
|
+
declare const plugin: Plugin;
|
|
28
|
+
export default plugin;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/code-metrics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA4P/C,QAAA,MAAM,MAAM,EAAE,MAgMb,CAAC;eAEa,MAAM"}
|
package/dist/code-metrics.d.ts
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* code-metrics plugin — lightweight per-file code metrics using regex-based
|
|
5
|
-
* line counting and complexity heuristics.
|
|
6
|
-
*
|
|
7
|
-
* Tools registered:
|
|
8
|
-
* - measure_code_metrics : Compute lines, comments, blanks, function count,
|
|
9
|
-
* and cyclomatic-complexity-like score for a file or directory.
|
|
10
|
-
* - metrics_status : Report config + counters.
|
|
11
|
-
*
|
|
12
|
-
* Hooks registered:
|
|
13
|
-
* - PostToolUse with matcher `write|edit` to source files, injecting a
|
|
14
|
-
* one-line metric summary of the changed file.
|
|
15
|
-
*
|
|
16
|
-
* Config (`config.extensions['code-metrics']`):
|
|
17
|
-
*
|
|
18
|
-
* ```jsonc
|
|
19
|
-
* {
|
|
20
|
-
* "enabled": true,
|
|
21
|
-
* "extensions": [".ts", ".tsx", ".js", ".jsx"],
|
|
22
|
-
* "maxFiles": 50
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
declare const plugin: Plugin;
|
|
30
|
-
|
|
31
|
-
export { plugin as default };
|
|
1
|
+
export * from './code-metrics/index.js';
|
|
2
|
+
export { default } from './code-metrics/index.js';
|
package/dist/code-metrics.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { readFileSync, existsSync, statSync, readdirSync } from 'fs';
|
|
2
|
-
import { resolve, isAbsolute, relative, extname } from 'path';
|
|
3
|
-
|
|
4
1
|
// src/code-metrics/index.ts
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
|
+
import { extname, isAbsolute, relative, resolve } from "node:path";
|
|
5
4
|
var API_VERSION = "^0.1.10";
|
|
6
5
|
var state = {
|
|
7
6
|
measureCount: 0,
|
|
@@ -86,33 +85,31 @@ function countFunctions(content) {
|
|
|
86
85
|
const declRe = /\bfunction\s+[A-Za-z_$][A-Za-z0-9_$]*\s*\(/g;
|
|
87
86
|
const methodRe = /\b[A-Za-z_$][A-Za-z0-9_$]*\s*\([^)]*\)\s*\{/g;
|
|
88
87
|
const arrowRe = /=>\s*(?:\{|\(|[^\s;{}])/g;
|
|
89
|
-
let m;
|
|
90
88
|
declRe.lastIndex = 0;
|
|
91
|
-
|
|
89
|
+
for (const _match of content.matchAll(declRe)) count++;
|
|
92
90
|
methodRe.lastIndex = 0;
|
|
93
|
-
|
|
94
|
-
const prefix = content.slice(0,
|
|
91
|
+
for (const match of content.matchAll(methodRe)) {
|
|
92
|
+
const prefix = content.slice(0, match.index).trimEnd();
|
|
95
93
|
if (/\bfunction\s*$/.test(prefix)) continue;
|
|
96
94
|
count++;
|
|
97
95
|
}
|
|
98
96
|
arrowRe.lastIndex = 0;
|
|
99
|
-
|
|
97
|
+
for (const _match of content.matchAll(arrowRe)) count++;
|
|
100
98
|
return count;
|
|
101
99
|
}
|
|
102
100
|
function countComplexity(content) {
|
|
103
101
|
const controlRe = /\b(if|else\s+if|for|while|switch|catch)\b/g;
|
|
104
102
|
const operatorRe = /[?&|]/g;
|
|
105
103
|
let complexity = 0;
|
|
106
|
-
let m;
|
|
107
104
|
controlRe.lastIndex = 0;
|
|
108
|
-
|
|
105
|
+
for (const _match of content.matchAll(controlRe)) complexity++;
|
|
109
106
|
operatorRe.lastIndex = 0;
|
|
110
|
-
|
|
111
|
-
const ch =
|
|
107
|
+
for (const match of content.matchAll(operatorRe)) {
|
|
108
|
+
const ch = match[0];
|
|
112
109
|
if (ch === "?") {
|
|
113
110
|
complexity++;
|
|
114
111
|
} else {
|
|
115
|
-
const next = content[
|
|
112
|
+
const next = content[match.index + 1];
|
|
116
113
|
if (next === ch) complexity++;
|
|
117
114
|
}
|
|
118
115
|
}
|
|
@@ -334,5 +331,6 @@ var plugin = {
|
|
|
334
331
|
}
|
|
335
332
|
};
|
|
336
333
|
var code_metrics_default = plugin;
|
|
337
|
-
|
|
338
|
-
|
|
334
|
+
export {
|
|
335
|
+
code_metrics_default as default
|
|
336
|
+
};
|