mdrefine 0.1.0-beta.1
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/CONTRIBUTING.md +10 -0
- package/LICENSE +21 -0
- package/README.md +133 -0
- package/SECURITY.md +16 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +158 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/config/load.d.ts +9 -0
- package/dist/config/load.js +75 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/resolve.d.ts +93 -0
- package/dist/config/resolve.js +110 -0
- package/dist/config/resolve.js.map +1 -0
- package/dist/core/directives.d.ts +3 -0
- package/dist/core/directives.js +48 -0
- package/dist/core/directives.js.map +1 -0
- package/dist/core/engine.d.ts +8 -0
- package/dist/core/engine.js +192 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/types.d.ts +92 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/dialects.d.ts +2 -0
- package/dist/rules/dialects.js +105 -0
- package/dist/rules/dialects.js.map +1 -0
- package/dist/rules/links.d.ts +2 -0
- package/dist/rules/links.js +238 -0
- package/dist/rules/links.js.map +1 -0
- package/dist/rules/style.d.ts +12 -0
- package/dist/rules/style.js +244 -0
- package/dist/rules/style.js.map +1 -0
- package/dist/syntax/obsidian.d.ts +33 -0
- package/dist/syntax/obsidian.js +126 -0
- package/dist/syntax/obsidian.js.map +1 -0
- package/dist/syntax/parse.d.ts +5 -0
- package/dist/syntax/parse.js +45 -0
- package/dist/syntax/parse.js.map +1 -0
- package/dist/workspace/files.d.ts +8 -0
- package/dist/workspace/files.js +98 -0
- package/dist/workspace/files.js.map +1 -0
- package/dist/workspace/index.d.ts +10 -0
- package/dist/workspace/index.js +100 -0
- package/dist/workspace/index.js.map +1 -0
- package/docs/cli.md +71 -0
- package/docs/configuration.md +171 -0
- package/docs/contributing.md +103 -0
- package/docs/design.md +79 -0
- package/docs/index.md +48 -0
- package/docs/obsidian.md +69 -0
- package/docs/plugins.md +114 -0
- package/docs/quick-start.md +101 -0
- package/docs/releases/0.1.0-beta.1.md +39 -0
- package/docs/releases.md +90 -0
- package/examples/github.jsonc +7 -0
- package/examples/obsidian.jsonc +8 -0
- package/package.json +101 -0
package/docs/obsidian.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Obsidian vaults
|
|
2
|
+
|
|
3
|
+
The Obsidian profile understands wikilinks, embeds, callouts, highlights,
|
|
4
|
+
comments, heading references, and block references. Its rules share the same
|
|
5
|
+
lint and format engine used for ordinary Markdown.
|
|
6
|
+
|
|
7
|
+
## Configure the vault
|
|
8
|
+
|
|
9
|
+
Create `mdtools.config.jsonc` at the vault root:
|
|
10
|
+
|
|
11
|
+
```jsonc
|
|
12
|
+
{
|
|
13
|
+
"extends": ["recommended", "obsidian"],
|
|
14
|
+
"ignore": ["Templates/**"],
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Use the vault root as `--root` so the CLI can inspect `.obsidian/app.json` and
|
|
19
|
+
resolve links across notes. Run these commands from a
|
|
20
|
+
[built checkout](quick-start.md):
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
node dist/cli/main.js lint --root "/path/to/vault" --json
|
|
24
|
+
node dist/cli/main.js format --root "/path/to/vault" --diff
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Enable source wrapping
|
|
28
|
+
|
|
29
|
+
Obsidian reflow requires `"strictLineBreaks": true` in `.obsidian/app.json` so
|
|
30
|
+
soft line breaks in source do not become visible line breaks in Reading view.
|
|
31
|
+
Preserve the file's other settings when changing this value. The CLI checks it
|
|
32
|
+
and never edits the settings file itself.
|
|
33
|
+
|
|
34
|
+
If that setting is not appropriate for your vault, disable `style/wrap`. Other
|
|
35
|
+
enabled rules can still run.
|
|
36
|
+
|
|
37
|
+
## Choose link policies deliberately
|
|
38
|
+
|
|
39
|
+
The recommended preset validates local links. To normalize verified destinations
|
|
40
|
+
to vault-relative paths wrapped in angle brackets:
|
|
41
|
+
|
|
42
|
+
```jsonc
|
|
43
|
+
{
|
|
44
|
+
"extends": ["recommended", "obsidian"],
|
|
45
|
+
"rules": {
|
|
46
|
+
"links/path": ["warn", { "style": "root", "brackets": "angle" }],
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For example, a resolved Markdown link can become `[Note](<Folder/Note.md>)`.
|
|
52
|
+
Missing or ambiguous destinations are never guessed. Unaliased wikilinks retain
|
|
53
|
+
their target spelling because changing it may change their visible label. Note
|
|
54
|
+
embeds remain embeds.
|
|
55
|
+
|
|
56
|
+
See [link policies](configuration.md#link-policies) for relative paths,
|
|
57
|
+
extension handling, and eligible Markdown/wikilink conversion. Path rewriting
|
|
58
|
+
and notation conversion should be run in separate passes.
|
|
59
|
+
|
|
60
|
+
## Review visible results
|
|
61
|
+
|
|
62
|
+
Preview changes with `--diff`, then use `--write` to apply them. Inspect complex
|
|
63
|
+
notes in Obsidian, especially when using additional plugins. The resolver does
|
|
64
|
+
not reproduce every Obsidian link-resolution behavior, and unsupported syntax
|
|
65
|
+
may need an ignore pattern or a
|
|
66
|
+
[suppression comment](configuration.md#suppressions).
|
|
67
|
+
|
|
68
|
+
Read the [current limitations](design.md#safety-boundaries) before a broad
|
|
69
|
+
vault-wide formatting pass.
|
package/docs/plugins.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Plugins and library API
|
|
2
|
+
|
|
3
|
+
The public API is exported from `mdrefine`. Follow the
|
|
4
|
+
[installation guide](quick-start.md) to install the npm package or build a
|
|
5
|
+
checkout as a local dependency. The API is provisional until a stable release.
|
|
6
|
+
|
|
7
|
+
## Library calls
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createWorkspace, format, lint } from "mdrefine";
|
|
11
|
+
|
|
12
|
+
const files = {
|
|
13
|
+
"note.md": "A *short* note with [a link](target.md).\n",
|
|
14
|
+
"target.md": "# Target\n",
|
|
15
|
+
};
|
|
16
|
+
const options = {
|
|
17
|
+
path: "note.md",
|
|
18
|
+
config: { extends: ["recommended", "github"] },
|
|
19
|
+
workspace: createWorkspace(files, { dialect: "github" }),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const diagnostics = lint(files["note.md"], options);
|
|
23
|
+
const result = format(files["note.md"], options);
|
|
24
|
+
// result: { output, changed, diagnostics }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Library calls do not read or write files. `path` and workspace keys use
|
|
28
|
+
forward-slash paths relative to the workspace root. Use `null` values for
|
|
29
|
+
non-Markdown attachments. Without a workspace, local target checks and path
|
|
30
|
+
rewriting are unavailable. Obsidian reflow also requires an explicit
|
|
31
|
+
`workspace.strictLineBreaks: true`; callers are responsible for verifying that
|
|
32
|
+
renderer setting.
|
|
33
|
+
|
|
34
|
+
`parse`, `range`, `textContent`, `resolveConfig`, `configSchema`, `presets`,
|
|
35
|
+
`builtInRules`, `ruleRegistry`, `applyEdits`, and `semanticFingerprint` are also
|
|
36
|
+
exported. `range(node)` returns `[start, end]` UTF-16 offsets into the original
|
|
37
|
+
source. `configSchema` is the configuration's JSON Schema; rule-specific schemas
|
|
38
|
+
live on rule objects.
|
|
39
|
+
|
|
40
|
+
## Rule plugins
|
|
41
|
+
|
|
42
|
+
Create `rules.mjs` beside the configuration:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
export default {
|
|
46
|
+
name: "local",
|
|
47
|
+
presets: {
|
|
48
|
+
recommended: { rules: { "local/initial-heading": "error" } },
|
|
49
|
+
},
|
|
50
|
+
rules: {
|
|
51
|
+
"initial-heading": {
|
|
52
|
+
description: "Require the first content block to be a heading.",
|
|
53
|
+
kind: "problem",
|
|
54
|
+
check({ document }) {
|
|
55
|
+
const first = document.tree.children.find(
|
|
56
|
+
(node) => node.type !== "yaml" && node.type !== "toml",
|
|
57
|
+
);
|
|
58
|
+
return first?.type === "heading"
|
|
59
|
+
? []
|
|
60
|
+
: [{ start: 0, message: "Start this document with a heading." }];
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Load it with:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"plugins": ["./rules.mjs"],
|
|
72
|
+
"extends": ["recommended", "local/recommended"]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Plugin module specifiers resolve relative to the config file, including npm
|
|
77
|
+
package names. Export a default plugin object. Library callers pass plugin
|
|
78
|
+
objects directly through `plugins`; a string list in a library configuration
|
|
79
|
+
does not perform module loading. Plugin names must be unique lowercase
|
|
80
|
+
identifiers beginning with a letter, using letters, digits, and hyphens. Rule
|
|
81
|
+
IDs are namespaced as `plugin-name/rule-name`; collisions are rejected.
|
|
82
|
+
|
|
83
|
+
`check` receives the parsed `document`, configured `options`, and optional
|
|
84
|
+
`workspace`. Return a list of findings containing `start`, optional `end`,
|
|
85
|
+
`message`, and optional `edit`. A rule may declare a JSON Schema in `schema` to
|
|
86
|
+
validate its options. Rules are synchronous and should not mutate the document,
|
|
87
|
+
perform I/O, or retain invocation-specific state.
|
|
88
|
+
|
|
89
|
+
Style rules use `kind: "style"` and can return edits of the form
|
|
90
|
+
`{ start, end, text }`. Their optional `phase` is `inline` (default), `block`,
|
|
91
|
+
or `document`. Problem rules use `kind: "problem"`; their edits are not applied
|
|
92
|
+
by `format`. Formatting runs phases repeatedly until stable, with a limit of
|
|
93
|
+
eight passes. Conflicting edits, oscillation, or a semantic change reject the
|
|
94
|
+
entire document's output.
|
|
95
|
+
|
|
96
|
+
Use built-in test helpers and fixture examples to verify custom style rules.
|
|
97
|
+
Plugins execute within the host process and are not sandboxed. Semantic checking
|
|
98
|
+
constrains the returned text, not arbitrary JavaScript behavior.
|
|
99
|
+
|
|
100
|
+
## Syntax extensions
|
|
101
|
+
|
|
102
|
+
An advanced plugin can provide `syntax: { micromark, mdast }`, containing
|
|
103
|
+
compatible tokenizer and AST extensions from the micromark/mdast ecosystem.
|
|
104
|
+
Extend the TypeScript mdast node maps for custom node types. Preserve source
|
|
105
|
+
positions and expose meaningful semantic fields: the engine compares node fields
|
|
106
|
+
other than `position` and `data` when checking formatting safety.
|
|
107
|
+
|
|
108
|
+
This is not a general remark-transform adapter. Existing syntax extensions can
|
|
109
|
+
be reused, but a remark plugin that mutates a tree must be adapted to the
|
|
110
|
+
rule/edit contract. There is no custom link resolver loader in CLI plugins yet;
|
|
111
|
+
library users can supply an implementation of the `Workspace` interface. Unknown
|
|
112
|
+
syntax is not automatically safe merely because a parser treats it as plain
|
|
113
|
+
text; use a supported dialect, an extension, an ignore pattern, or a suppression
|
|
114
|
+
for application-specific constructs.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Quick start
|
|
2
|
+
|
|
3
|
+
Get the CLI running, select a profile, and preview a formatting pass before
|
|
4
|
+
writing changes.
|
|
5
|
+
|
|
6
|
+
## Install the beta
|
|
7
|
+
|
|
8
|
+
The CLI requires Node.js 22.12 or newer. Install the package in your document
|
|
9
|
+
workspace:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install --save-dev --save-exact mdrefine@0.1.0-beta.1
|
|
13
|
+
npx --no-install mdtools --help
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The npm package is `mdrefine`; the executable is `mdtools`. Prereleases use the
|
|
17
|
+
`beta` channel. See
|
|
18
|
+
[versions and availability](releases.md#versions-and-availability) for registry
|
|
19
|
+
checks and release announcements.
|
|
20
|
+
|
|
21
|
+
Run the examples below from the workspace where you installed the package.
|
|
22
|
+
`--no-install` prevents fetching a different package if the local executable is
|
|
23
|
+
missing. Replace `/path/to/documents` with your document folder; quote paths
|
|
24
|
+
containing spaces.
|
|
25
|
+
|
|
26
|
+
## Install from the repository
|
|
27
|
+
|
|
28
|
+
To build a checkout instead, use Node.js 22.22.2+ or 24.15.0+ and npm 10 or
|
|
29
|
+
newer; Node.js 24 LTS is preferred.
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
git clone https://github.com/viell-dev/slop-markdown-tools.git
|
|
33
|
+
cd slop-markdown-tools
|
|
34
|
+
npm ci
|
|
35
|
+
npm run build
|
|
36
|
+
node dist/cli/main.js --help
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
From that checkout, use `node dist/cli/main.js` in place of
|
|
40
|
+
`npx --no-install mdtools` in the examples below.
|
|
41
|
+
|
|
42
|
+
## Choose a configuration
|
|
43
|
+
|
|
44
|
+
Create `mdtools.config.jsonc` in your document folder:
|
|
45
|
+
|
|
46
|
+
```jsonc
|
|
47
|
+
{
|
|
48
|
+
"extends": ["recommended", "github"],
|
|
49
|
+
"ignore": ["vendor/**", "**/*.external.md"],
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The recommended preset wraps prose at **80 columns**, uses `_` for emphasis and
|
|
54
|
+
`**` for strong text, ensures a final newline, and validates local links. The
|
|
55
|
+
GitHub preset adds table, task marker, and alert marker rules. The configuration
|
|
56
|
+
controls both linting and formatting.
|
|
57
|
+
|
|
58
|
+
For CommonMark, use only `"recommended"`. For a vault, replace `"github"` with
|
|
59
|
+
`"obsidian"` and follow the [Obsidian setup](obsidian.md).
|
|
60
|
+
|
|
61
|
+
## Lint without writing
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npx --no-install mdtools lint --root /path/to/documents
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Lint reports diagnostics and never changes files. Add `--json` for structured
|
|
68
|
+
output, or `--max-warnings 0` to make warnings fail an automated check.
|
|
69
|
+
|
|
70
|
+
## Preview and apply formatting
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
npx --no-install mdtools format --root /path/to/documents --diff
|
|
74
|
+
npx --no-install mdtools format --root /path/to/documents --write
|
|
75
|
+
npx --no-install mdtools format --root /path/to/documents --check
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Review the diff before running `--write`. The final check exits with code `1` if
|
|
79
|
+
formatting changes remain. Formatting may still report lint problems that
|
|
80
|
+
require a manual correction; inspect diagnostics as well as the exit code.
|
|
81
|
+
|
|
82
|
+
## Adjust the rules
|
|
83
|
+
|
|
84
|
+
Override a preset rule by adding a `rules` object:
|
|
85
|
+
|
|
86
|
+
```jsonc
|
|
87
|
+
{
|
|
88
|
+
"extends": ["recommended", "github"],
|
|
89
|
+
"rules": {
|
|
90
|
+
"style/wrap": ["warn", { "width": 100 }],
|
|
91
|
+
"style/emphasis": "off",
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This wraps at 100 columns and preserves existing emphasis delimiters. Use
|
|
97
|
+
`"extends": []` to start with no enabled rules.
|
|
98
|
+
|
|
99
|
+
Continue with [CLI workflows](cli.md) for automation and file selection, or
|
|
100
|
+
[configuration and rules](configuration.md) for presets, links, overrides, and
|
|
101
|
+
suppression comments.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# mdrefine 0.1.0-beta.1
|
|
2
|
+
|
|
3
|
+
First public beta of Markdown Tools. npm package: `mdrefine`; executable:
|
|
4
|
+
`mdtools`. Requires Node.js 22.12 or newer.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- Separate lint and format commands with JSON reports, diff previews, stdin,
|
|
9
|
+
check mode, and explicit file writes.
|
|
10
|
+
- Configurable presets, per-file overrides, suppression comments, and custom
|
|
11
|
+
JavaScript rule and syntax plugins.
|
|
12
|
+
- Source-preserving formatting for CommonMark, GitHub Markdown, and Obsidian,
|
|
13
|
+
with a default wrap width of 80 columns.
|
|
14
|
+
- Local link and fragment validation, verified link path and notation changes,
|
|
15
|
+
GitHub tables and alerts, and Obsidian wikilinks, embeds, callouts, and block
|
|
16
|
+
references.
|
|
17
|
+
- Obsidian paragraph reflow requires verified `strictLineBreaks: true`.
|
|
18
|
+
|
|
19
|
+
## Packaging and maintenance
|
|
20
|
+
|
|
21
|
+
- The package name changed from the unpublished `@viell-dev/markdown-tools`
|
|
22
|
+
checkout name to `mdrefine`. Update library imports; the `mdtools` command,
|
|
23
|
+
configuration names, and suppression directives remain unchanged.
|
|
24
|
+
- Installed package checks cover the command shim, library exports, and public
|
|
25
|
+
TypeScript declarations on the supported CI platforms.
|
|
26
|
+
- Manual release preparation retains a tested tarball and checksum. Publishing
|
|
27
|
+
is separately gated and uses the npm `beta` channel.
|
|
28
|
+
- PR-based maintenance applies to prereleases as well as stable versions.
|
|
29
|
+
- Multiline inline code is preserved during reflow instead of triggering an
|
|
30
|
+
unsafe-format rejection.
|
|
31
|
+
|
|
32
|
+
## Known limits
|
|
33
|
+
|
|
34
|
+
The plugin API and configuration are provisional. Ambiguous links are reported
|
|
35
|
+
without guessing; unsupported syntax is preserved conservatively. Not every
|
|
36
|
+
Markdown layout is normalized. Review the
|
|
37
|
+
[design and limitations](https://viell-dev.github.io/slop-markdown-tools/design.html)
|
|
38
|
+
before adopting the beta across a vault. This project is developed and
|
|
39
|
+
maintained by agents without assumed human review.
|
package/docs/releases.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Releases
|
|
2
|
+
|
|
3
|
+
## Versions and availability
|
|
4
|
+
|
|
5
|
+
These documents cover `mdrefine@0.1.0-beta.1`. The executable is `mdtools`;
|
|
6
|
+
prereleases use npm's `beta` channel. Read the
|
|
7
|
+
[beta.1 release notes](releases/0.1.0-beta.1.md) for changes and limitations.
|
|
8
|
+
|
|
9
|
+
The registry is the source of truth for package availability:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm view mdrefine@0.1.0-beta.1 version --registry=https://registry.npmjs.org/
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
An `E404` means the requested package or version is unavailable. A version in
|
|
16
|
+
this repository or its documentation does not imply publication. Check
|
|
17
|
+
[GitHub releases](https://github.com/viell-dev/slop-markdown-tools/releases) for
|
|
18
|
+
release announcements and downloadable artifacts.
|
|
19
|
+
|
|
20
|
+
## Prepare without publishing
|
|
21
|
+
|
|
22
|
+
Use Node.js 24 and npm 10 or newer from a clean checkout:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm ci
|
|
26
|
+
npm run release:prepare
|
|
27
|
+
npm publish ./artifacts/mdrefine-0.1.0-beta.1.tgz --dry-run --ignore-scripts --access public --tag beta
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Preparation runs all checks, packs the allowlisted files, installs that exact
|
|
31
|
+
tarball into a temporary consumer, exercises the installed command and library,
|
|
32
|
+
and compiles a TypeScript consumer. It retains the tested tarball, file
|
|
33
|
+
manifest, and SHA-256 checksum in ignored `artifacts/`. No registry upload, Git
|
|
34
|
+
tag, or GitHub release occurs. Local artifacts must be regenerated after any
|
|
35
|
+
change.
|
|
36
|
+
|
|
37
|
+
The manual **Release** GitHub Actions workflow performs the same checks plus a
|
|
38
|
+
dependency audit and uploads the artifact for 14 days. Leave `publish` false to
|
|
39
|
+
prepare only. CI independently checks Linux, macOS, Windows, and Node.js 22/24.
|
|
40
|
+
|
|
41
|
+
## Publication prerequisites
|
|
42
|
+
|
|
43
|
+
Publication requires explicit operator authorization. Preparing a PR or artifact
|
|
44
|
+
does not supply that authorization. Before the first publication:
|
|
45
|
+
|
|
46
|
+
1. Merge the release PR with all required checks passing. Review the tarball
|
|
47
|
+
manifest, release notes, version, and registry name again.
|
|
48
|
+
2. Arrange npm account access, verified email, and required two-factor
|
|
49
|
+
authentication. Verify the intended account with `npm whoami`. Bootstrap
|
|
50
|
+
publication may need an authenticated local publish before package settings
|
|
51
|
+
are available for trusted publishing.
|
|
52
|
+
3. Configure npm's
|
|
53
|
+
[trusted publisher](https://docs.npmjs.com/trusted-publishers/) for user
|
|
54
|
+
`viell-dev`, repository `slop-markdown-tools`, workflow `release.yml`, and
|
|
55
|
+
environment `npm-release`. Allow direct `npm publish`. No long-lived npm
|
|
56
|
+
token is stored in GitHub.
|
|
57
|
+
4. Restrict the GitHub `npm-release` environment to `main` and configure an
|
|
58
|
+
approval gate if an independent approver is available. Verify branch rules
|
|
59
|
+
still require PRs and the four CI checks. The workflow uses Node.js 24 and
|
|
60
|
+
checks that npm supports trusted publishing.
|
|
61
|
+
5. Only after authorization and authentication setup, set repository variable
|
|
62
|
+
`NPM_PUBLISH_ENABLED` to `true`. It is disabled during preparation.
|
|
63
|
+
|
|
64
|
+
## Publish an authorized beta
|
|
65
|
+
|
|
66
|
+
Dispatch **Release** on `main` with the exact package version, `publish: true`,
|
|
67
|
+
and the actual publishing agent's identity as `model via harness`. The workflow
|
|
68
|
+
builds and checks the package again, verifies the artifact checksum, publishes
|
|
69
|
+
that tarball to npm's `beta` channel with provenance, and creates a GitHub
|
|
70
|
+
prerelease at the workflow's commit. Tags use exact versions without a `v`
|
|
71
|
+
prefix. Stable publication deliberately needs a separate policy change; this
|
|
72
|
+
workflow accepts only beta versions and never assigns npm's `latest` tag.
|
|
73
|
+
|
|
74
|
+
For an authenticated first publication that cannot use OIDC yet, use the exact
|
|
75
|
+
reviewed tarball with `npm publish <tarball> --ignore-scripts --access public
|
|
76
|
+
--tag beta` only after authorization. Then create the matching GitHub
|
|
77
|
+
prerelease at the exact source commit, attach the tarball and checksum, and use
|
|
78
|
+
the reviewed notes with the actual publishing agent attribution. Complete npm
|
|
79
|
+
trusted publisher setup afterward.
|
|
80
|
+
|
|
81
|
+
If npm succeeds but GitHub release creation fails, do not republish or bump the
|
|
82
|
+
version blindly. Verify the published package integrity against the retained
|
|
83
|
+
artifact and finish only the missing GitHub step at the same commit. Published
|
|
84
|
+
versions, tags, and release assets must never be overwritten; corrections use a
|
|
85
|
+
new version. The workflow refuses an existing npm version or tag to make a
|
|
86
|
+
partial release visible instead of silently accepting it.
|
|
87
|
+
|
|
88
|
+
After publication, verify registry metadata, the `beta` dist-tag, a fresh
|
|
89
|
+
installation, the GitHub release and its assets, and the documentation site. All
|
|
90
|
+
subsequent changes, including prerelease maintenance, continue through PRs.
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mdrefine",
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"description": "Configurable Markdown linting and formatting for CommonMark, GitHub, and Obsidian",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "viell",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/viell-dev/slop-markdown-tools.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/viell-dev/slop-markdown-tools/issues"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22.12.0"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"mdtools": "dist/cli/main.js"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org/",
|
|
24
|
+
"tag": "beta"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"docs/*.md",
|
|
35
|
+
"docs/releases/*.md",
|
|
36
|
+
"examples",
|
|
37
|
+
"README.md",
|
|
38
|
+
"CONTRIBUTING.md",
|
|
39
|
+
"SECURITY.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.build.json",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"pretest": "npm run build",
|
|
47
|
+
"test:package": "run-s build test:package:installed",
|
|
48
|
+
"lint": "eslint .",
|
|
49
|
+
"format": "run-s format:code format:docs",
|
|
50
|
+
"format:code": "prettier --write .",
|
|
51
|
+
"format:docs": "run-s build format:docs:write",
|
|
52
|
+
"format:docs:check": "run-s build lint:docs format:docs:verify",
|
|
53
|
+
"format:check": "run-p format:code:check format:docs:check",
|
|
54
|
+
"check": "npm-run-all --parallel typecheck lint format:check docs:build --sequential test",
|
|
55
|
+
"prepack": "npm run build",
|
|
56
|
+
"test:package:installed": "node scripts/package-smoke.mjs",
|
|
57
|
+
"format:docs:write": "node dist/cli/main.js format --write",
|
|
58
|
+
"lint:docs": "node dist/cli/main.js lint --max-warnings 0",
|
|
59
|
+
"format:docs:verify": "node dist/cli/main.js format --check",
|
|
60
|
+
"format:code:check": "prettier --check .",
|
|
61
|
+
"docs:dev": "vitepress dev docs",
|
|
62
|
+
"docs:build": "vitepress build docs",
|
|
63
|
+
"docs:preview": "vitepress preview docs",
|
|
64
|
+
"release:prepare": "run-s check release:pack",
|
|
65
|
+
"release:pack": "node scripts/package-smoke.mjs --retain"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"ajv": "8.20.0",
|
|
69
|
+
"commander": "15.0.0",
|
|
70
|
+
"diff": "9.0.0",
|
|
71
|
+
"github-slugger": "2.0.0",
|
|
72
|
+
"ignore": "7.0.9",
|
|
73
|
+
"jsonc-parser": "3.3.1",
|
|
74
|
+
"mdast-util-from-markdown": "2.0.3",
|
|
75
|
+
"mdast-util-frontmatter": "2.0.1",
|
|
76
|
+
"mdast-util-gfm": "3.1.0",
|
|
77
|
+
"mdast-util-math": "3.0.0",
|
|
78
|
+
"micromark-extension-frontmatter": "2.0.0",
|
|
79
|
+
"micromark-extension-gfm": "3.0.0",
|
|
80
|
+
"micromark-extension-math": "3.1.0",
|
|
81
|
+
"micromark-util-types": "2.0.2",
|
|
82
|
+
"minimatch": "10.2.6",
|
|
83
|
+
"string-width": "8.2.2",
|
|
84
|
+
"unist-util-visit": "5.1.0"
|
|
85
|
+
},
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@eslint/js": "10.0.1",
|
|
88
|
+
"@types/mdast": "4.0.4",
|
|
89
|
+
"@types/node": "26.6.1",
|
|
90
|
+
"@types/unist": "3.0.3",
|
|
91
|
+
"eslint": "10.10.0",
|
|
92
|
+
"fast-check": "4.10.1",
|
|
93
|
+
"npm-run-all2": "9.0.3",
|
|
94
|
+
"prettier": "3.9.8",
|
|
95
|
+
"typescript": "6.0.3",
|
|
96
|
+
"typescript-eslint": "8.70.0",
|
|
97
|
+
"vitepress": "2.0.0-alpha.20",
|
|
98
|
+
"vitest": "5.0.1"
|
|
99
|
+
},
|
|
100
|
+
"homepage": "https://viell-dev.github.io/slop-markdown-tools/"
|
|
101
|
+
}
|