@muxion/dev-config 0.2.1 → 0.3.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/agents/pluggability.md +22 -0
- package/agents/repository.md +3 -4
- package/agents/rust-core.md +1 -0
- package/agents/rust-ffi.md +2 -2
- package/dist/agents-check.d.ts +3 -0
- package/dist/agents-check.d.ts.map +1 -1
- package/dist/agents-check.js +23 -28
- package/dist/agents-check.js.map +1 -1
- package/dist/agents-lints.d.ts +11 -0
- package/dist/agents-lints.d.ts.map +1 -0
- package/dist/agents-lints.js +116 -0
- package/dist/agents-lints.js.map +1 -0
- package/dist/agents-settings.d.ts +7 -0
- package/dist/agents-settings.d.ts.map +1 -0
- package/dist/agents-settings.js +44 -0
- package/dist/agents-settings.js.map +1 -0
- package/dist/agents.js +21 -3
- package/dist/agents.js.map +1 -1
- package/dist/files.d.ts +4 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +27 -0
- package/dist/files.js.map +1 -0
- package/dist/json.d.ts +3 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +8 -0
- package/dist/json.js.map +1 -0
- package/package.json +5 -1
- package/skills/muxion-release/SKILL.md +18 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- '**/packages/core-*/**'
|
|
4
|
+
- '**/packages/libp2p-*/**'
|
|
5
|
+
- '**/ARCHITECTURE.md'
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pluggability Rules
|
|
9
|
+
|
|
10
|
+
This layer adds to the engineering principles.
|
|
11
|
+
|
|
12
|
+
- Follow the principles, diagrams, and step registry in the muxion-core `ARCHITECTURE.md`, and in the `ARCHITECTURE.md` of the repository that you change, if it has one.
|
|
13
|
+
- Give each step in the workflow diagram an interface, also with one implementation.
|
|
14
|
+
- Put per-packet steps in Rust traits. Put I/O, clock, signing, and seed steps in host interfaces.
|
|
15
|
+
- Let a plug decide policy. Keep validation, limits, and replay checks in the core.
|
|
16
|
+
- Use `Box<dyn Trait>` for plugs. Use generics only when a benchmark shows a need.
|
|
17
|
+
- Use a factory for a plug with per-path or per-connection state. Do not name a concrete plug at a construction site.
|
|
18
|
+
- Give time to a plug as an argument. Do not let a plug own clocks, threads, I/O, or randomness.
|
|
19
|
+
- Add an ABI discriminator for a plug only when a second built-in implementation exists.
|
|
20
|
+
- Update the diagram and the registry in the commit that adds, removes, or moves a step.
|
|
21
|
+
- Run the contract test suite of an interface against each implementation.
|
|
22
|
+
- The rule "Add an abstraction only for a current need" does not apply to steps in the workflow diagram.
|
package/agents/repository.md
CHANGED
|
@@ -24,6 +24,8 @@ This layer adds to the engineering principles.
|
|
|
24
24
|
- Keep the root `.oxfmtrc.mjs` limited to the shared configuration re-export.
|
|
25
25
|
- Do not copy or override shared TypeScript, Oxlint, or Oxfmt policy.
|
|
26
26
|
- Link `.claude/rules/muxion` to `../../node_modules/@muxion/dev-config/agents`. Do not copy the shared rules.
|
|
27
|
+
- Link `.claude/skills/muxion-release` to `../../node_modules/@muxion/dev-config/skills/muxion-release`.
|
|
28
|
+
- Commit `.claude/settings.json` with the permissions that `muxion-agents check` requires.
|
|
27
29
|
|
|
28
30
|
## Verification
|
|
29
31
|
|
|
@@ -32,7 +34,4 @@ This layer adds to the engineering principles.
|
|
|
32
34
|
|
|
33
35
|
## Releases
|
|
34
36
|
|
|
35
|
-
-
|
|
36
|
-
- Publish public packages only with `npm run publish` in the child repository. It runs the `muxion-publish` tool from `@muxion/dev-config`. To publish all child repositories in dependency order, run `npm run publish:all` in `muxion-all`.
|
|
37
|
-
- Do not run `npm publish` directly.
|
|
38
|
-
- Run the publish script with `-- --dry-run` first. If it reports a changed package, increase the version of that package before you publish.
|
|
37
|
+
- To publish, use the `muxion-release` skill. Do not run `npm publish` directly.
|
package/agents/rust-core.md
CHANGED
|
@@ -15,3 +15,4 @@ This layer adds to the Rust layer.
|
|
|
15
15
|
- Do not iterate a hash map or hash set when the order changes the output (`clippy::iter_over_hash_type`).
|
|
16
16
|
- Keep the core ready for `no_std` with `alloc`. Use `core` and `alloc` paths (`clippy::std_instead_of_core`, `clippy::std_instead_of_alloc`).
|
|
17
17
|
- Give each queue, buffer, and map that peer input can grow a limit from configuration.
|
|
18
|
+
- Put the lints of this layer in `#![deny(...)]` at the crate root. This replaces the Rust layer rule "Do not put `#![deny]` at crate roots" for the lints of this layer only.
|
package/agents/rust-ffi.md
CHANGED
package/dist/agents-check.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export declare const agentsLinkPath = ".claude/rules/muxion";
|
|
2
2
|
export declare const agentsLinkTarget = "../../node_modules/@muxion/dev-config/agents";
|
|
3
|
+
export declare const skillLinkPath = ".claude/skills/muxion-release";
|
|
4
|
+
export declare const skillLinkTarget = "../../node_modules/@muxion/dev-config/skills/muxion-release";
|
|
3
5
|
export declare const isTargetPackageName: (name: string) => boolean;
|
|
6
|
+
export declare const readPackageDirectories: (root: string) => Promise<string[]>;
|
|
4
7
|
export declare const checkRepository: (root: string) => Promise<string[]>;
|
|
5
8
|
//# sourceMappingURL=agents-check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents-check.d.ts","sourceRoot":"","sources":["../src/agents-check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agents-check.d.ts","sourceRoot":"","sources":["../src/agents-check.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,yBAAyB,CAAA;AACpD,eAAO,MAAM,gBAAgB,iDAAiD,CAAA;AAE9E,eAAO,MAAM,aAAa,kCAAkC,CAAA;AAC5D,eAAO,MAAM,eAAe,gEAAgE,CAAA;AAI5F,eAAO,MAAM,mBAAmB,SAAU,MAAM,KAAG,OACgC,CAAA;AAwDnF,eAAO,MAAM,sBAAsB,SAAgB,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,CAU3E,CAAA;AAqBD,eAAO,MAAM,eAAe,SAAgB,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,CAGpE,CAAA"}
|
package/dist/agents-check.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
// oxlint-disable-next-line import/no-nodejs-modules -- The check reads the repository files.
|
|
2
|
-
import { lstat, readdir, readFile, readlink
|
|
2
|
+
import { lstat, readdir, readFile, readlink } from 'node:fs/promises';
|
|
3
3
|
// oxlint-disable-next-line import/no-nodejs-modules -- The check makes repository paths.
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
|
+
import { checkSettings } from './agents-settings.js';
|
|
6
|
+
import { exists, isNotFound } from './files.js';
|
|
5
7
|
export const agentsLinkPath = '.claude/rules/muxion';
|
|
6
8
|
export const agentsLinkTarget = '../../node_modules/@muxion/dev-config/agents';
|
|
9
|
+
export const skillLinkPath = '.claude/skills/muxion-release';
|
|
10
|
+
export const skillLinkTarget = '../../node_modules/@muxion/dev-config/skills/muxion-release';
|
|
7
11
|
const targetSuffixes = ['-js', '-node', '-web', '-rust'];
|
|
8
12
|
export const isTargetPackageName = (name) => targetSuffixes.some((suffix) => name.endsWith(suffix)) || name.includes('-node-');
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
catch (error) {
|
|
16
|
-
if (isNotFound(error)) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const checkLink = async (root) => {
|
|
23
|
-
const link = join(root, agentsLinkPath);
|
|
13
|
+
const links = [
|
|
14
|
+
{ path: agentsLinkPath, target: agentsLinkTarget, version: '0.2.0' },
|
|
15
|
+
{ path: skillLinkPath, target: skillLinkTarget, version: '0.3.0' },
|
|
16
|
+
];
|
|
17
|
+
const checkLink = async (root, { path, target, version }) => {
|
|
18
|
+
const link = join(root, path);
|
|
24
19
|
let isLink;
|
|
25
20
|
try {
|
|
26
21
|
const stats = await lstat(link);
|
|
@@ -28,20 +23,20 @@ const checkLink = async (root) => {
|
|
|
28
23
|
}
|
|
29
24
|
catch (error) {
|
|
30
25
|
if (isNotFound(error)) {
|
|
31
|
-
return [`${
|
|
26
|
+
return [`${path} does not exist. Make it a symlink to ${target}.`];
|
|
32
27
|
}
|
|
33
28
|
throw error;
|
|
34
29
|
}
|
|
35
30
|
if (!isLink) {
|
|
36
|
-
return [`${
|
|
31
|
+
return [`${path} is not a symlink. Make it a symlink to ${target}.`];
|
|
37
32
|
}
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
return [`${
|
|
33
|
+
const actual = await readlink(link);
|
|
34
|
+
if (actual !== target) {
|
|
35
|
+
return [`${path} points to ${actual}. It must point to ${target}.`];
|
|
41
36
|
}
|
|
42
|
-
if (!(await exists(join(dirname(link),
|
|
37
|
+
if (!(await exists(join(dirname(link), actual)))) {
|
|
43
38
|
return [
|
|
44
|
-
`${
|
|
39
|
+
`${path} does not resolve. Run npm install, and use @muxion/dev-config ${version} or later.`,
|
|
45
40
|
];
|
|
46
41
|
}
|
|
47
42
|
return [];
|
|
@@ -61,7 +56,7 @@ const readExempt = async (root) => {
|
|
|
61
56
|
}
|
|
62
57
|
return exempt;
|
|
63
58
|
};
|
|
64
|
-
const readPackageDirectories = async (root) => {
|
|
59
|
+
export const readPackageDirectories = async (root) => {
|
|
65
60
|
try {
|
|
66
61
|
const entries = await readdir(join(root, 'packages'), { withFileTypes: true });
|
|
67
62
|
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
@@ -86,8 +81,8 @@ const checkPackages = async (root) => {
|
|
|
86
81
|
}
|
|
87
82
|
return errors;
|
|
88
83
|
};
|
|
89
|
-
export const checkRepository = async (root) =>
|
|
90
|
-
|
|
91
|
-
...(await checkPackages(root))
|
|
92
|
-
|
|
84
|
+
export const checkRepository = async (root) => {
|
|
85
|
+
const linkErrors = await Promise.all(links.map((link) => checkLink(root, link)));
|
|
86
|
+
return [...linkErrors.flat(), ...(await checkSettings(root)), ...(await checkPackages(root))];
|
|
87
|
+
};
|
|
93
88
|
//# sourceMappingURL=agents-check.js.map
|
package/dist/agents-check.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents-check.js","sourceRoot":"","sources":["../src/agents-check.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"agents-check.js","sourceRoot":"","sources":["../src/agents-check.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACrE,yFAAyF;AACzF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAA;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,8CAA8C,CAAA;AAE9E,MAAM,CAAC,MAAM,aAAa,GAAG,+BAA+B,CAAA;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAG,6DAA6D,CAAA;AAE5F,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AAExD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAW,EAAE,CAC3D,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAQnF,MAAM,KAAK,GAAoB;IAC7B,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,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|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type LintScope = 'core-crate' | 'oxlint' | 'workspace';
|
|
2
|
+
export interface LayerLint {
|
|
3
|
+
readonly layer: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly scope: LintScope;
|
|
6
|
+
}
|
|
7
|
+
export declare const sharedOxlintPath = "node_modules/@muxion/dev-config/oxlint.json";
|
|
8
|
+
export declare const parseLayerLints: (layer: string, text: string) => string[];
|
|
9
|
+
export declare const readLayerLints: (directory: string) => Promise<LayerLint[]>;
|
|
10
|
+
export declare const checkLints: (root: string, lints: readonly LayerLint[]) => Promise<string[]>;
|
|
11
|
+
//# sourceMappingURL=agents-lints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-lints.d.ts","sourceRoot":"","sources":["../src/agents-lints.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE7D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAC1B;AAED,eAAO,MAAM,gBAAgB,gDAAgD,CAAA;AAoB7E,eAAO,MAAM,eAAe,UAAW,MAAM,QAAQ,MAAM,KAAG,MAAM,EAUnE,CAAA;AAED,eAAO,MAAM,cAAc,cAAqB,MAAM,KAAG,OAAO,CAAC,SAAS,EAAE,CAsB3E,CAAA;AAyED,eAAO,MAAM,UAAU,SAAgB,MAAM,SAAS,SAAS,SAAS,EAAE,KAAG,OAAO,CAAC,MAAM,EAAE,CAiB5F,CAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The check reads the layer files.
|
|
2
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
3
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The check makes repository paths.
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { parse } from 'smol-toml';
|
|
6
|
+
import { readPackageDirectories } from './agents-check.js';
|
|
7
|
+
import { readOptional } from './files.js';
|
|
8
|
+
import { field, isRecord } from './json.js';
|
|
9
|
+
export const sharedOxlintPath = 'node_modules/@muxion/dev-config/oxlint.json';
|
|
10
|
+
const oxlintPlugins = ['eslint', 'import', 'node', 'oxc', 'typescript', 'unicorn'];
|
|
11
|
+
const layerScopes = new Map([
|
|
12
|
+
['rust-core.md', 'core-crate'],
|
|
13
|
+
['rust-ffi.md', 'workspace'],
|
|
14
|
+
['rust.md', 'workspace'],
|
|
15
|
+
['ts-js.md', 'oxlint'],
|
|
16
|
+
['ts-node.md', 'oxlint'],
|
|
17
|
+
['ts-web.md', 'oxlint'],
|
|
18
|
+
['typescript.md', 'oxlint'],
|
|
19
|
+
]);
|
|
20
|
+
const isLintSpan = (span) => span.startsWith('clippy::') || oxlintPlugins.some((plugin) => span.startsWith(`${plugin}/`));
|
|
21
|
+
const isValidLintName = (span) => /^clippy::[a-z0-9_]+$/u.test(span) || /^[a-z]+\/[a-z0-9-]+$/u.test(span);
|
|
22
|
+
export const parseLayerLints = (layer, text) => {
|
|
23
|
+
const spans = [...text.matchAll(/`(?<span>[^`\n]+)`/gu)].map((match) => match.groups?.['span'] ?? '');
|
|
24
|
+
const lints = spans.filter((span) => isLintSpan(span));
|
|
25
|
+
const invalid = lints.find((span) => !isValidLintName(span));
|
|
26
|
+
if (invalid !== undefined) {
|
|
27
|
+
throw new Error(`${layer}: ${invalid} is not a valid lint name.`);
|
|
28
|
+
}
|
|
29
|
+
return lints;
|
|
30
|
+
};
|
|
31
|
+
export const readLayerLints = async (directory) => {
|
|
32
|
+
const entries = await readdir(directory);
|
|
33
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- sort() on a fresh array is safe; toSorted() is not in the configured lib
|
|
34
|
+
const names = entries.filter((name) => name.endsWith('.md')).sort();
|
|
35
|
+
const layers = await Promise.all(names.map(async (layer) => ({
|
|
36
|
+
layer,
|
|
37
|
+
lints: parseLayerLints(layer, await readFile(join(directory, layer), 'utf8')),
|
|
38
|
+
})));
|
|
39
|
+
return layers.flatMap(({ layer, lints }) => {
|
|
40
|
+
if (lints.length === 0) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const scope = layerScopes.get(layer);
|
|
44
|
+
if (scope === undefined) {
|
|
45
|
+
throw new Error(`${layer} names lints, but muxion-agents lints does not know where to check them. Add the layer to layerScopes in agents-lints.ts.`);
|
|
46
|
+
}
|
|
47
|
+
return lints.map((name) => ({ layer, name, scope }));
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const namesIn = (lints, scope) => [
|
|
51
|
+
...new Set(lints.filter((lint) => lint.scope === scope).map(({ name }) => name)),
|
|
52
|
+
];
|
|
53
|
+
const clippyLevel = (entry) => {
|
|
54
|
+
if (isRecord(entry)) {
|
|
55
|
+
return entry['level'];
|
|
56
|
+
}
|
|
57
|
+
return entry;
|
|
58
|
+
};
|
|
59
|
+
const isDenied = (level) => level === 'deny' || level === 'forbid';
|
|
60
|
+
const checkWorkspaceLints = (manifest, names) => {
|
|
61
|
+
const table = field(field(field(manifest, 'workspace'), 'lints'), 'clippy');
|
|
62
|
+
return names
|
|
63
|
+
.map((name) => name.slice('clippy::'.length))
|
|
64
|
+
.filter((lint) => !isDenied(clippyLevel(field(table, lint))))
|
|
65
|
+
.map((lint) => `Cargo.toml: set ${lint} = "deny" in [workspace.lints.clippy].`);
|
|
66
|
+
};
|
|
67
|
+
const deniedAtCrateRoot = (source) => new Set([...source.matchAll(/#!\[(?:deny|forbid)\((?<list>[^\]]*)\)\]/gu)].flatMap((match) => (match.groups?.['list'] ?? '').split(',').map((lint) => lint.trim())));
|
|
68
|
+
const checkCoreCrate = async (root, crate, names) => {
|
|
69
|
+
const path = `packages/${crate}/src/lib.rs`;
|
|
70
|
+
const source = await readOptional(join(root, path));
|
|
71
|
+
if (source === undefined) {
|
|
72
|
+
return [`${path} does not exist. A core crate must have a crate root with the core lints.`];
|
|
73
|
+
}
|
|
74
|
+
const denied = deniedAtCrateRoot(source);
|
|
75
|
+
return names
|
|
76
|
+
.filter((name) => !denied.has(name))
|
|
77
|
+
.map((name) => `${path}: add ${name} to a crate-root #![deny(...)] attribute.`);
|
|
78
|
+
};
|
|
79
|
+
const oxlintLevel = (entry) => {
|
|
80
|
+
if (Array.isArray(entry)) {
|
|
81
|
+
return entry[0];
|
|
82
|
+
}
|
|
83
|
+
return entry;
|
|
84
|
+
};
|
|
85
|
+
const isError = (level) => level === 'error' || level === 'deny' || level === 2;
|
|
86
|
+
const checkOxlintRules = async (root, names) => {
|
|
87
|
+
if (names.length === 0) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
const text = await readOptional(join(root, sharedOxlintPath));
|
|
91
|
+
if (text === undefined) {
|
|
92
|
+
return [`${sharedOxlintPath} does not exist. Run npm install.`];
|
|
93
|
+
}
|
|
94
|
+
const config = JSON.parse(text);
|
|
95
|
+
const rules = field(config, 'rules');
|
|
96
|
+
return names
|
|
97
|
+
.filter((name) => !isError(oxlintLevel(field(rules, name))))
|
|
98
|
+
.map((name) => `${sharedOxlintPath}: set "${name}": "error" in rules. Change it in @muxion/dev-config.`);
|
|
99
|
+
};
|
|
100
|
+
export const checkLints = async (root, lints) => {
|
|
101
|
+
const oxlintErrors = await checkOxlintRules(root, namesIn(lints, 'oxlint'));
|
|
102
|
+
const cargo = await readOptional(join(root, 'Cargo.toml'));
|
|
103
|
+
if (cargo === undefined) {
|
|
104
|
+
return oxlintErrors;
|
|
105
|
+
}
|
|
106
|
+
const directories = await readPackageDirectories(root);
|
|
107
|
+
const crates = directories.filter((name) => name.endsWith('core-rust'));
|
|
108
|
+
const coreNames = namesIn(lints, 'core-crate');
|
|
109
|
+
const coreErrors = await Promise.all(crates.map((crate) => checkCoreCrate(root, crate, coreNames)));
|
|
110
|
+
return [
|
|
111
|
+
...oxlintErrors,
|
|
112
|
+
...checkWorkspaceLints(parse(cargo), namesIn(lints, 'workspace')),
|
|
113
|
+
...coreErrors.flat(),
|
|
114
|
+
];
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=agents-lints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-lints.js","sourceRoot":"","sources":["../src/agents-lints.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACpD,yFAAyF;AACzF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAU3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,6CAA6C,CAAA;AAE7E,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,CAAC,CAAA;AAElF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAoB;IAC7C,CAAC,cAAc,EAAE,YAAY,CAAC;IAC9B,CAAC,aAAa,EAAE,WAAW,CAAC;IAC5B,CAAC,SAAS,EAAE,WAAW,CAAC;IACxB,CAAC,UAAU,EAAE,QAAQ,CAAC;IACtB,CAAC,YAAY,EAAE,QAAQ,CAAC;IACxB,CAAC,WAAW,EAAE,QAAQ,CAAC;IACvB,CAAC,eAAe,EAAE,QAAQ,CAAC;CAC5B,CAAC,CAAA;AAEF,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CAC3C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,aAAa,CAAC,IAAI,CA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AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const settingsPath = ".claude/settings.json";
|
|
2
|
+
export declare const requiredPermissions: {
|
|
3
|
+
readonly ask: readonly ['Bash(npm deprecate:*)', 'Bash(npm run publish:*)', 'Bash(npm run publish:all:*)'];
|
|
4
|
+
readonly deny: readonly ['Bash(npm publish:*)', 'Bash(yarn:*)'];
|
|
5
|
+
};
|
|
6
|
+
export declare const checkSettings: (root: string) => Promise<string[]>;
|
|
7
|
+
//# sourceMappingURL=agents-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-settings.d.ts","sourceRoot":"","sources":["../src/agents-settings.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,0BAA0B,CAAA;AAEnD,eAAO,MAAM,mBAAmB;aAC9B,GAAG,YAAG,uBAAuB,EAAE,yBAAyB,EAAE,6BAA6B;aACvF,IAAI,YAAG,qBAAqB,EAAE,cAAc;CACpC,CAAA;AAmBV,eAAO,MAAM,aAAa,SAAgB,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,CAkBlE,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The check makes repository paths.
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { readOptional } from './files.js';
|
|
4
|
+
import { field } from './json.js';
|
|
5
|
+
export const settingsPath = '.claude/settings.json';
|
|
6
|
+
export const requiredPermissions = {
|
|
7
|
+
ask: ['Bash(npm deprecate:*)', 'Bash(npm run publish:*)', 'Bash(npm run publish:all:*)'],
|
|
8
|
+
deny: ['Bash(npm publish:*)', 'Bash(yarn:*)'],
|
|
9
|
+
};
|
|
10
|
+
const permissionLists = ['deny', 'ask'];
|
|
11
|
+
const stringList = (value) => {
|
|
12
|
+
if (!Array.isArray(value)) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
return value.filter((item) => typeof item === 'string');
|
|
16
|
+
};
|
|
17
|
+
const parseJson = (text) => {
|
|
18
|
+
try {
|
|
19
|
+
return { valid: true, value: JSON.parse(text) };
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { valid: false, value: undefined };
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export const checkSettings = async (root) => {
|
|
26
|
+
const text = await readOptional(join(root, settingsPath));
|
|
27
|
+
if (text === undefined) {
|
|
28
|
+
return [
|
|
29
|
+
`${settingsPath} does not exist. Add it with the permissions that @muxion/dev-config requires.`,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
const settings = parseJson(text);
|
|
33
|
+
if (!settings.valid) {
|
|
34
|
+
return [`${settingsPath} is not valid JSON.`];
|
|
35
|
+
}
|
|
36
|
+
const permissions = field(settings.value, 'permissions');
|
|
37
|
+
return permissionLists.flatMap((list) => {
|
|
38
|
+
const present = stringList(field(permissions, list));
|
|
39
|
+
return requiredPermissions[list]
|
|
40
|
+
.filter((entry) => !present.includes(entry))
|
|
41
|
+
.map((entry) => `${settingsPath}: add "${entry}" to permissions.${list}.`);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=agents-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-settings.js","sourceRoot":"","sources":["../src/agents-settings.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,MAAM,CAAC,MAAM,YAAY,GAAG,uBAAuB,CAAA;AAEnD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,CAAC,uBAAuB,EAAE,yBAAyB,EAAE,6BAA6B,CAAC;IACxF,IAAI,EAAE,CAAC,qBAAqB,EAAE,cAAc,CAAC;C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UAAU,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAA;QACpD,OAAO,mBAAmB,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;aAC3C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,YAAY,UAAU,KAAK,oBAAoB,IAAI,GAAG,CAAC,CAAA;IAC9E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/dist/agents.js
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The entry point finds the shipped layer files.
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
2
4
|
// oxlint-disable-next-line import/no-nodejs-modules -- The entry point reads the command arguments.
|
|
3
5
|
import { parseArgs } from 'node:util';
|
|
4
6
|
import { checkRepository } from './agents-check.js';
|
|
7
|
+
import { checkLints, readLayerLints } from './agents-lints.js';
|
|
8
|
+
const usage = 'Usage: muxion-agents check | muxion-agents lints';
|
|
9
|
+
const layersDirectory = fileURLToPath(new URL('../agents/', import.meta.url));
|
|
10
|
+
const run = async (command) => {
|
|
11
|
+
switch (command) {
|
|
12
|
+
case 'check': {
|
|
13
|
+
return checkRepository(process.cwd());
|
|
14
|
+
}
|
|
15
|
+
case 'lints': {
|
|
16
|
+
return checkLints(process.cwd(), await readLayerLints(layersDirectory));
|
|
17
|
+
}
|
|
18
|
+
default: {
|
|
19
|
+
throw new Error(usage);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
5
23
|
try {
|
|
6
24
|
const { positionals } = parseArgs({ allowPositionals: true, options: {} });
|
|
7
|
-
if (positionals.length !== 1
|
|
8
|
-
throw new Error(
|
|
25
|
+
if (positionals.length !== 1) {
|
|
26
|
+
throw new Error(usage);
|
|
9
27
|
}
|
|
10
|
-
const errors = await
|
|
28
|
+
const errors = await run(positionals[0]);
|
|
11
29
|
for (const error of errors) {
|
|
12
30
|
console.error(`error: ${error}`);
|
|
13
31
|
}
|
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":";AACA,oGAAoG;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":";AACA,sGAAsG;AACtG,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,oGAAoG;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAE9D,MAAM,KAAK,GAAG,kDAAkD,CAAA;AAChE,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAE7E,MAAM,GAAG,GAAG,KAAK,EAAE,OAAe,EAAqB,EAAE;IACvD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,OAAO,EAAE,CAAC;YACb,OAAO,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QACvC,CAAC;QACD,KAAK,OAAO,EAAE,CAAC;YACb,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,cAAc,CAAC,eAAe,CAAC,CAAC,CAAA;QACzE,CAAC;QACD,SAAS,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,I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ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The checks read repository files.
|
|
2
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
3
|
+
export const isNotFound = (error) => error instanceof Error && 'code' in error && error.code === 'ENOENT';
|
|
4
|
+
export const exists = async (path) => {
|
|
5
|
+
try {
|
|
6
|
+
await stat(path);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (isNotFound(error)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const readOptional = async (path) => {
|
|
17
|
+
try {
|
|
18
|
+
return await readFile(path, 'utf8');
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (isNotFound(error)) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAW,EAAE,CACpD,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAA;AAEtE,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE;IAC7D,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;QAChB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAA+B,EAAE;IAC9E,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA"}
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,UAAW,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACH,CAAA;AAEtE,eAAO,MAAM,KAAK,UAAW,OAAO,OAAO,MAAM,KAAG,OAKnD,CAAA"}
|
package/dist/json.js
ADDED
package/dist/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAC3E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,GAAW,EAAW,EAAE;IAC5D,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muxion/dev-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dist",
|
|
16
16
|
"oxfmt.js",
|
|
17
17
|
"oxlint.json",
|
|
18
|
+
"skills",
|
|
18
19
|
"tsconfig"
|
|
19
20
|
],
|
|
20
21
|
"type": "module",
|
|
@@ -38,6 +39,9 @@
|
|
|
38
39
|
"test": "vitest run",
|
|
39
40
|
"lint": "oxlint src test --tsconfig tsconfig.test.json --deny-warnings && tsc -p tsconfig.test.json"
|
|
40
41
|
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"smol-toml": "^1.9.0"
|
|
44
|
+
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@types/node": "*",
|
|
43
47
|
"oxlint": "*",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: muxion-release
|
|
3
|
+
description: Use when you publish, release, or increase the version of a Muxion package, or when a task needs npm publish, npm deprecate, or publish:all.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Muxion Release
|
|
7
|
+
|
|
8
|
+
Use this procedure to publish packages from a Muxion repository. Do not run `npm publish` directly. The Claude Code settings refuse it.
|
|
9
|
+
|
|
10
|
+
1. In the child repository, run `npm run verify`. If it fails, stop and fix the cause.
|
|
11
|
+
2. Run `npm run publish -- --dry-run`. Read which packages it reports as changed.
|
|
12
|
+
3. Increase the version of each changed package:
|
|
13
|
+
- Increase the patch version for a compatible change.
|
|
14
|
+
- Increase the minor version for a breaking change in a `0.x` version.
|
|
15
|
+
- Change the exact versions in the dependent packages of the same repository. Then run `npm install` to update `package-lock.json`.
|
|
16
|
+
4. Run `npm run verify` again. Commit the version change.
|
|
17
|
+
5. Ask the user before the real publish. Then run `npm run publish` in the child repository. To publish all child repositories in dependency order, run `npm run publish:all` in `muxion-all`.
|
|
18
|
+
6. Ask the user before you run `npm deprecate`. Give the old package name and its replacement.
|