patdown 0.4.0 → 0.5.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 (43) hide show
  1. package/README.md +46 -11
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +45 -20
  4. package/dist/index.d.ts +5 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +4 -1
  7. package/dist/patdown-console-rule-blocks.d.ts +13 -0
  8. package/dist/patdown-console-rule-blocks.d.ts.map +1 -0
  9. package/dist/patdown-console-rule-blocks.js +80 -0
  10. package/dist/patdown-evidence-regions.d.ts +44 -0
  11. package/dist/patdown-evidence-regions.d.ts.map +1 -0
  12. package/dist/patdown-evidence-regions.js +124 -0
  13. package/dist/patdown-github-actions-env.d.ts +6 -0
  14. package/dist/patdown-github-actions-env.d.ts.map +1 -0
  15. package/dist/patdown-github-actions-env.js +17 -0
  16. package/dist/patdown-github-actions-output.d.ts +8 -0
  17. package/dist/patdown-github-actions-output.d.ts.map +1 -0
  18. package/dist/patdown-github-actions-output.js +52 -0
  19. package/dist/patdown-github-actions-summary.d.ts +19 -0
  20. package/dist/patdown-github-actions-summary.d.ts.map +1 -0
  21. package/dist/patdown-github-actions-summary.js +171 -0
  22. package/dist/patdown-glob.d.ts +9 -0
  23. package/dist/patdown-glob.d.ts.map +1 -0
  24. package/dist/patdown-glob.js +21 -0
  25. package/dist/patdown-judge.d.ts +25 -0
  26. package/dist/patdown-judge.d.ts.map +1 -1
  27. package/dist/patdown-judge.js +23 -0
  28. package/dist/patdown-lint-files.d.ts +14 -0
  29. package/dist/patdown-lint-files.d.ts.map +1 -0
  30. package/dist/patdown-lint-files.js +75 -0
  31. package/dist/patdown-lint.d.ts +2 -1
  32. package/dist/patdown-lint.d.ts.map +1 -1
  33. package/dist/patdown-lint.js +57 -21
  34. package/dist/patdown-output.d.ts +22 -4
  35. package/dist/patdown-output.d.ts.map +1 -1
  36. package/dist/patdown-output.js +79 -14
  37. package/dist/run-patdown-cli.d.ts +3 -1
  38. package/dist/run-patdown-cli.d.ts.map +1 -1
  39. package/dist/run-patdown-cli.js +16 -3
  40. package/dist/typesafe-judge.d.ts +1 -0
  41. package/dist/typesafe-judge.d.ts.map +1 -1
  42. package/dist/typesafe-judge.js +15 -1
  43. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"patdown-output.d.ts","sourceRoot":"","sources":["../src/patdown-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACrF,OAAO,EAAW,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAExD,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG/E,+FAA+F;AAC/F,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IACrC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAA;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC1B,CAAA;;8BA4D2B,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;0BAC/C,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;8BACvC,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;kCAChE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;0BAClD,CACrB,QA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atdownYesThreshold } from '@patdown/rules';
2
- import { Console, Context, Effect, Layer } from 'effect';
2
+ import { Console, Context, Effect, Layer, Ref } from 'effect';
3
+ import { formatPatdownLintResultLine, formatPatdownRuleBlock, } from '#src/patdown-console-rule-blocks';
3
4
  import { patdownJudgmentIsYes } from '#src/patdown-judge';
4
5
  import { formatPatdownProbabilityBar } from '#src/patdown-probability-bar';
5
6
  function formatPatdownElapsedMs(elapsedMs) {
@@ -14,13 +15,6 @@ function formatPatdownAnswer(judgment, verbose, yesThreshold, elapsedMs) {
14
15
  ? `${answer} (${formatPatdownProbability(judgment.yesProbability, yesThreshold, elapsedMs)})`
15
16
  : answer;
16
17
  }
17
- function formatPatdownLintResult(result, verbose) {
18
- const verdict = result.violated ? 'FAIL' : 'PASS';
19
- const line = `${verdict} ${result.filePath}: ${result.ruleTitle}`;
20
- return verbose
21
- ? `${line} (${formatPatdownProbability(result.violationProbability, result.yesThreshold, result.elapsedMs)})`
22
- : line;
23
- }
24
18
  function formatPatdownRulesDocument(document) {
25
19
  const lines = [
26
20
  `patdown: ${String(document.patdownRules.length)} rules from ${document.patdownRulesFilePath}`,
@@ -38,16 +32,87 @@ function formatPatdownRulesDocument(document) {
38
32
  /** Swappable output service. Probability details are opt-in. */
39
33
  export class PatdownOutput extends Context.Service()('@patdown/cli/PatdownOutput') {
40
34
  }
41
- /** Default human-readable output, without provider-specific vocabulary. */
42
- export const PatdownOutputLive = Layer.succeed(PatdownOutput, {
35
+ function flushPatdownConsoleRuleBlock(buffer) {
36
+ if (buffer.ruleTitle === null)
37
+ return Effect.void;
38
+ return Console.log(formatPatdownRuleBlock(buffer.ruleTitle, buffer.results));
39
+ }
40
+ /** One-line writers shared with GitHub Actions job logs. */
41
+ export const patdownStreamingHumanOutput = {
43
42
  writeLintFailed: (elapsedMs) => Console.log(elapsedMs === undefined
44
43
  ? 'patdown: failed'
45
44
  : `patdown: failed (elapsed: ${formatPatdownElapsedMs(elapsedMs)})`),
46
45
  writeLintOk: (elapsedMs) => Console.log(elapsedMs === undefined
47
- ? 'patdown: ok'
48
- : `patdown: ok (elapsed: ${formatPatdownElapsedMs(elapsedMs)})`),
49
- writeLintResult: (result, verbose) => Console.log(formatPatdownLintResult(result, verbose)),
46
+ ? 'patdown: passed'
47
+ : `patdown: passed (elapsed: ${formatPatdownElapsedMs(elapsedMs)})`),
48
+ writeLintResult: (result, verbose) => Console.log(verbose
49
+ ? `${formatPatdownLintResultLine(result)} (${formatPatdownProbability(result.violationProbability, result.yesThreshold, result.elapsedMs)})`
50
+ : formatPatdownLintResultLine(result)),
50
51
  writeNoFilesMatched: (title) => Console.log(`patdown: no files matched ${title}`),
51
52
  writeAnswer: (judgment, verbose, yesThreshold = defaultPatdownYesThreshold, elapsedMs = 0) => Console.log(formatPatdownAnswer(judgment, verbose, yesThreshold, elapsedMs)),
52
53
  writeRulesDocument: (document) => Console.log(formatPatdownRulesDocument(document)),
53
- });
54
+ };
55
+ /**
56
+ * Local human output. Quiet mode streams one PASS/FAIL line per judgment. Verbose mode groups
57
+ * judgments into per-rule console blocks.
58
+ */
59
+ export const PatdownOutputLive = Layer.effect(PatdownOutput, Effect.gen(function* () {
60
+ const buffer = yield* Ref.make({
61
+ ruleTitle: null,
62
+ results: [],
63
+ });
64
+ const flush = () => Effect.gen(function* () {
65
+ const current = yield* Ref.get(buffer);
66
+ yield* flushPatdownConsoleRuleBlock(current);
67
+ yield* Ref.set(buffer, { ruleTitle: null, results: [] });
68
+ });
69
+ const writers = {
70
+ writeAnswer: patdownStreamingHumanOutput.writeAnswer,
71
+ writeRulesDocument: patdownStreamingHumanOutput.writeRulesDocument,
72
+ writeLintResult: (result, verbose) => {
73
+ if (!verbose) {
74
+ return patdownStreamingHumanOutput.writeLintResult(result, false);
75
+ }
76
+ return Effect.gen(function* () {
77
+ const current = yield* Ref.get(buffer);
78
+ if (current.ruleTitle !== null && current.ruleTitle !== result.ruleTitle) {
79
+ yield* flushPatdownConsoleRuleBlock(current);
80
+ yield* Ref.set(buffer, {
81
+ ruleTitle: result.ruleTitle,
82
+ results: [result],
83
+ });
84
+ return;
85
+ }
86
+ yield* Ref.set(buffer, {
87
+ ruleTitle: result.ruleTitle,
88
+ results: [...current.results, result],
89
+ });
90
+ });
91
+ },
92
+ writeNoFilesMatched: (title) => Effect.gen(function* () {
93
+ yield* flush();
94
+ yield* Console.log(formatPatdownRuleBlock(title, []));
95
+ }),
96
+ writeLintOk: (elapsedMs) => Effect.gen(function* () {
97
+ const current = yield* Ref.get(buffer);
98
+ const hadVerboseBlock = current.ruleTitle !== null;
99
+ yield* flush();
100
+ if (hadVerboseBlock) {
101
+ yield* Console.log('');
102
+ }
103
+ yield* patdownStreamingHumanOutput.writeLintOk(elapsedMs);
104
+ }),
105
+ writeLintFailed: (elapsedMs) => Effect.gen(function* () {
106
+ const current = yield* Ref.get(buffer);
107
+ const hadVerboseBlock = current.ruleTitle !== null;
108
+ yield* flush();
109
+ if (hadVerboseBlock) {
110
+ yield* Console.log('');
111
+ }
112
+ yield* patdownStreamingHumanOutput.writeLintFailed(elapsedMs);
113
+ }),
114
+ };
115
+ return writers;
116
+ }));
117
+ /** @deprecated Use patdownStreamingHumanOutput for one-line logs. */
118
+ export const patdownHumanOutput = patdownStreamingHumanOutput;
@@ -6,7 +6,9 @@ import { type PatdownOutput } from '#src/patdown-output';
6
6
  import type { PatdownRuleSourceLayer } from '#src/patdown-rule-source-adapter';
7
7
  /**
8
8
  * Returns a runnable CLI Effect. A supplied rule source disables discovery; argv excludes node and
9
- * script. The third and fourth arguments replace the judge and output layers independently.
9
+ * script. The third and fourth arguments replace the judge and output layers independently. Without
10
+ * an output layer, GitHub Actions summary/annotations turn on when GITHUB_ACTIONS and
11
+ * GITHUB_STEP_SUMMARY are set, unless argv includes --no-github.
10
12
  */
11
13
  export declare function runPatdownCli(ruleSourceLayer?: PatdownRuleSourceLayer, argv?: readonly string[], judgeLayer?: Layer.Layer<PatdownJudge, PatdownJudgeFailed>, outputLayer?: Layer.Layer<PatdownOutput>): Effect.Effect<void, PatdownRulesLoadFailed | PatdownJudgeFailed | CliError>;
12
14
  //# sourceMappingURL=run-patdown-cli.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-patdown-cli.d.ts","sourceRoot":"","sources":["../src/run-patdown-cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAI5D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAA;AAG9E;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,eAAe,CAAC,EAAE,sBAAsB,EACxC,IAAI,GAAE,SAAS,MAAM,EAA0B,EAC/C,UAAU,GAAE,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,kBAAkB,CAAqB,EAC7E,WAAW,GAAE,KAAK,CAAC,KAAK,CAAC,aAAa,CAAqB,GACzD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB,GAAG,QAAQ,CAAC,CAS7E"}
1
+ {"version":3,"file":"run-patdown-cli.d.ts","sourceRoot":"","sources":["../src/run-patdown-cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAM5D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAA;AAO9E;;;;;GAKG;AACH,wBAAgB,aAAa,CAC5B,eAAe,CAAC,EAAE,sBAAsB,EACxC,IAAI,GAAE,SAAS,MAAM,EAA0B,EAC/C,UAAU,GAAE,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,kBAAkB,CAAqB,EAC7E,WAAW,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,GACtC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB,GAAG,QAAQ,CAAC,CAmB7E"}
@@ -4,14 +4,27 @@ import { Effect, Layer } from 'effect';
4
4
  import { Command } from 'effect/unstable/cli';
5
5
  import { makePatdownCommand } from '#src/cli';
6
6
  import { patdownCliVersion } from '#src/patdown-cli-version';
7
+ import { patdownGitHubActionsIsEnabled } from '#src/patdown-github-actions-env';
8
+ import { PatdownGitHubActionsOutputLive } from '#src/patdown-github-actions-output';
7
9
  import { PatdownOutputLive } from '#src/patdown-output';
8
10
  import { TypeSafeJudgeLive } from '#src/typesafe-judge';
11
+ function argvDisablesPatdownGitHubActions(argv) {
12
+ return argv.includes('--no-github');
13
+ }
9
14
  /**
10
15
  * Returns a runnable CLI Effect. A supplied rule source disables discovery; argv excludes node and
11
- * script. The third and fourth arguments replace the judge and output layers independently.
16
+ * script. The third and fourth arguments replace the judge and output layers independently. Without
17
+ * an output layer, GitHub Actions summary/annotations turn on when GITHUB_ACTIONS and
18
+ * GITHUB_STEP_SUMMARY are set, unless argv includes --no-github.
12
19
  */
13
- export function runPatdownCli(ruleSourceLayer, argv = process.argv.slice(2), judgeLayer = TypeSafeJudgeLive, outputLayer = PatdownOutputLive) {
20
+ export function runPatdownCli(ruleSourceLayer, argv = process.argv.slice(2), judgeLayer = TypeSafeJudgeLive, outputLayer) {
14
21
  const command = makePatdownCommand(ruleSourceLayer === undefined);
15
22
  const source = ruleSourceLayer ?? MarkdownPatdownRuleSourceLive;
16
- return Command.runWith(command, { version: patdownCliVersion })(argv).pipe(Effect.provide(Layer.mergeAll(source, judgeLayer, outputLayer).pipe(Layer.provideMerge(NodeServices.layer))));
23
+ return Effect.gen(function* () {
24
+ const selectedOutput = outputLayer ??
25
+ (argvDisablesPatdownGitHubActions(argv) || !(yield* patdownGitHubActionsIsEnabled)
26
+ ? PatdownOutputLive
27
+ : PatdownGitHubActionsOutputLive);
28
+ yield* Command.runWith(command, { version: patdownCliVersion })(argv).pipe(Effect.provide(Layer.mergeAll(source, judgeLayer, selectedOutput).pipe(Layer.provideMerge(NodeServices.layer))));
29
+ });
17
30
  }
@@ -1,5 +1,6 @@
1
1
  import { Layer } from 'effect';
2
2
  import { PatdownJudge } from '#src/patdown-judge';
3
+ export { patdownEvidenceMinConfidence } from '#src/patdown-evidence-regions';
3
4
  /**
4
5
  * Temporary TypeSafe backend. Replace this layer with Effect Decision/DecisionModel when available;
5
6
  * see issue #1.
@@ -1 +1 @@
1
- {"version":3,"file":"typesafe-judge.d.ts","sourceRoot":"","sources":["../src/typesafe-judge.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAA;AAGtC,OAAO,EAAE,YAAY,EAA4C,MAAM,oBAAoB,CAAA;AAE3F;;;GAGG;AACH,eAAO,MAAM,iBAAiB,yCAcS,CAAA"}
1
+ {"version":3,"file":"typesafe-judge.d.ts","sourceRoot":"","sources":["../src/typesafe-judge.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAA;AAOtC,OAAO,EACN,YAAY,EAIZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAE5E;;;GAGG;AACH,eAAO,MAAM,iBAAiB,yCAmCS,CAAA"}
@@ -1,7 +1,9 @@
1
1
  import { JevSystemOne, JevSystemOneLive } from '@patdown/jev';
2
2
  import { Effect, Layer } from 'effect';
3
3
  import { FetchHttpClient } from 'effect/unstable/http';
4
- import { PatdownJudge, PatdownJudgeFailed } from '#src/patdown-judge';
4
+ import { patdownEvidenceMinConfidence, patdownEvidenceNoMatchChoice, } from '#src/patdown-evidence-regions';
5
+ import { PatdownJudge, PatdownJudgeFailed, } from '#src/patdown-judge';
6
+ export { patdownEvidenceMinConfidence } from '#src/patdown-evidence-regions';
5
7
  /**
6
8
  * Temporary TypeSafe backend. Replace this layer with Effect Decision/DecisionModel when available;
7
9
  * see issue #1.
@@ -10,5 +12,17 @@ export const TypeSafeJudgeLive = Layer.effect(PatdownJudge, Effect.gen(function*
10
12
  const client = yield* JevSystemOne;
11
13
  return {
12
14
  ask: (question, inputText) => client.askNoul(question, inputText).pipe(Effect.map((answer) => ({ yesProbability: answer.noul })), Effect.mapError((error) => new PatdownJudgeFailed({ message: error.message })), Effect.provide(FetchHttpClient.layer)),
15
+ locateEvidence: (question, inputText, criteria) => client.askChoice(question, inputText, criteria).pipe(Effect.map((answer) => {
16
+ if (answer.choice === patdownEvidenceNoMatchChoice())
17
+ return null;
18
+ if (answer.confidence < patdownEvidenceMinConfidence)
19
+ return null;
20
+ if (!(answer.choice in criteria))
21
+ return null;
22
+ return {
23
+ regionId: answer.choice,
24
+ confidence: answer.confidence,
25
+ };
26
+ }), Effect.mapError((error) => new PatdownJudgeFailed({ message: error.message })), Effect.provide(FetchHttpClient.layer)),
13
27
  };
14
28
  })).pipe(Layer.provide(JevSystemOneLive));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patdown",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Standalone CLI that lints a tree against fuzzy markdown rules",
5
5
  "homepage": "https://github.com/tyler-dot-earth/patdown",
6
6
  "bugs": {
@@ -48,8 +48,8 @@
48
48
  "@effect/platform-node": "4.0.0-rc.112",
49
49
  "effect": "4.0.0-rc.112",
50
50
  "import-meta-resolve": "4.2.0",
51
- "@patdown/jev": "0.4.0",
52
- "@patdown/rules": "0.4.0"
51
+ "@patdown/jev": "0.5.0",
52
+ "@patdown/rules": "0.5.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@effect/language-service": "0.87.2",
@@ -61,8 +61,8 @@
61
61
  "oxlint-tsgolint": "^7.0.2001",
62
62
  "typescript": "7.0.2",
63
63
  "vitest": "^4.1.11",
64
- "@patdown/tsconfig": "0.0.0",
65
- "@patdown/oxlint-config": "0.0.0"
64
+ "@patdown/oxlint-config": "0.0.0",
65
+ "@patdown/tsconfig": "0.0.0"
66
66
  },
67
67
  "engines": {
68
68
  "node": ">=22.22.2"