@six5536/smllm 0.0.0 → 0.4.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/README.md CHANGED
@@ -1,3 +1,59 @@
1
- # @six5536/smllm
1
+ # smllm
2
2
 
3
- This version only reserves the name. smllm publishes its real versions from https://github.com/six5536/smllm.
3
+ smllm runs state machines for large language model (LLM) coding agents. This README helps you
4
+ install smllm from npm and run its first commands. It covers installation, usage, where to find
5
+ the full documentation, and the licence.
6
+
7
+ You describe a workflow in YAML, as a subset of XState v5, and smllm drives the agent through it.
8
+ smllm gives the agent each state's instructions. When the agent tries to stop, smllm offers the
9
+ events that the agent can fire through one Model Context Protocol (MCP) tool. smllm works with
10
+ Claude Code, Codex, Gemini CLI, Cursor, and other agent harnesses.
11
+
12
+ - [Install](#install)
13
+ - [Usage](#usage)
14
+ - [Documentation](#documentation)
15
+ - [Licence](#licence)
16
+
17
+ ## Install
18
+
19
+ Install the package globally:
20
+
21
+ ```sh
22
+ npm install -g @six5536/smllm
23
+ ```
24
+
25
+ This package is a thin launcher. It declares a prebuilt binary for each supported platform as an
26
+ `optionalDependency`, and npm installs only the one that matches your machine. A small JavaScript
27
+ shim then runs the binary.
28
+
29
+ The package supports Linux and macOS on `x64` and `arm64`, and Windows on `x64`. On any other
30
+ platform, or to build from source, install smllm with the Rust toolchain instead:
31
+
32
+ ```sh
33
+ cargo install smllm
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ These commands create a config, scaffold a state machine, check it, and connect smllm to an
39
+ agent:
40
+
41
+ ```sh
42
+ smllm init # .smllm/config.toml
43
+ smllm new dev --write # scaffold a state machine
44
+ smllm validate # findings as file:line: level: message
45
+ smllm harness install claude # hooks + MCP tool for Claude Code (or codex, gemini, cursor, …, all)
46
+ ```
47
+
48
+ smllm exits with `0` on success, `1` when it finds errors (config errors, a rejected event, or a
49
+ failed hook), and `2` on a usage or internal error.
50
+
51
+ ## Documentation
52
+
53
+ The [smllm repository on GitHub](https://github.com/six5536/smllm#readme) has the full usage
54
+ guide and the notes on development.
55
+
56
+ ## Licence
57
+
58
+ smllm is licensed under the MIT licence. The
59
+ [LICENSE](https://github.com/six5536/smllm/blob/main/LICENSE) file has the full text.
package/bin/smllm.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // Thin launcher: resolve the prebuilt binary for this platform and run it,
5
+ // forwarding arguments, stdio, and the exit code.
6
+
7
+ const { spawnSync } = require("node:child_process");
8
+ const { resolveBinary, exitCode } = require("../lib/binary");
9
+
10
+ let binary;
11
+ try {
12
+ binary = resolveBinary(process.platform, process.arch);
13
+ } catch (err) {
14
+ process.stderr.write(`${err.message}\n`);
15
+ process.exit(1);
16
+ }
17
+
18
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
19
+
20
+ if (result.error) {
21
+ process.stderr.write(`failed to run smllm: ${result.error.message}\n`);
22
+ process.exit(1);
23
+ }
24
+
25
+ process.exit(exitCode(result));
package/lib/binary.js ADDED
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ // Maps the host platform to the prebuilt binary package and resolves the binary
4
+ // path. Logic is dependency-injected (platform, arch, requireResolve) so it is
5
+ // unit-testable without the platform packages actually being installed.
6
+
7
+ const PACKAGES = {
8
+ "linux x64": "@six5536/smllm-linux-x64",
9
+ "linux arm64": "@six5536/smllm-linux-arm64",
10
+ "darwin x64": "@six5536/smllm-darwin-x64",
11
+ "darwin arm64": "@six5536/smllm-darwin-arm64",
12
+ "win32 x64": "@six5536/smllm-win32-x64",
13
+ };
14
+
15
+ const SUPPORTED = Object.keys(PACKAGES)
16
+ .map((k) => k.replace(" ", "-"))
17
+ .join(", ");
18
+
19
+ /** Return the platform package name for a platform/arch, or null if unsupported. */
20
+ function selectPackage(platform, arch) {
21
+ return PACKAGES[`${platform} ${arch}`] || null;
22
+ }
23
+
24
+ /** The binary file name inside a platform package. */
25
+ function binaryName(platform) {
26
+ return platform === "win32" ? "smllm.exe" : "smllm";
27
+ }
28
+
29
+ /**
30
+ * Resolve the absolute path to the prebuilt binary for the given platform/arch.
31
+ * Throws if the platform has no binary, or if it has one but the package was
32
+ * never installed — each error names the fix. `requireResolve` defaults to the
33
+ * real `require.resolve`.
34
+ */
35
+ function resolveBinary(platform, arch, requireResolve = require.resolve) {
36
+ const pkg = selectPackage(platform, arch);
37
+ if (!pkg) {
38
+ throw new Error(
39
+ `No prebuilt smllm binary for ${platform}-${arch}.\n` +
40
+ `Supported platforms: ${SUPPORTED}.\n` +
41
+ `Install from source instead: cargo install smllm`,
42
+ );
43
+ }
44
+ try {
45
+ return requireResolve(`${pkg}/bin/${binaryName(platform)}`);
46
+ } catch {
47
+ throw new Error(
48
+ `The smllm platform package "${pkg}" is not installed.\n` +
49
+ `Optional dependencies were most likely skipped during install.\n` +
50
+ `Reinstall smllm, or build from source: cargo install smllm`,
51
+ );
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Map a `spawnSync` result to the exit code this process should use.
57
+ *
58
+ * A child killed by a signal reports `status === null` and `signal === "SIGINT"`
59
+ * etc. Shells encode that as `128 + signum`, so a Ctrl-C'd run exits 130 rather
60
+ * than a misleading 1. `signals` is injected for testability and defaults to
61
+ * Node's own table.
62
+ */
63
+ function exitCode(result, signals = require("node:os").constants.signals) {
64
+ if (result.signal) {
65
+ const signum = signals[result.signal];
66
+ if (signum) {
67
+ return 128 + signum;
68
+ }
69
+ }
70
+ return result.status === null ? 1 : result.status;
71
+ }
72
+
73
+ module.exports = {
74
+ selectPackage,
75
+ binaryName,
76
+ resolveBinary,
77
+ exitCode,
78
+ PACKAGES,
79
+ SUPPORTED,
80
+ };
package/package.json CHANGED
@@ -1,10 +1,46 @@
1
1
  {
2
2
  "name": "@six5536/smllm",
3
- "version": "0.0.0",
4
- "description": "Reserves the name for smllm's first release, so that its trusted publisher can be set up. Install a later version.",
3
+ "version": "0.4.1",
4
+ "description": "State machines for LLM agents: declarative workflows that drive a coding agent through its hooks and one MCP tool.",
5
5
  "homepage": "https://github.com/six5536/smllm#readme",
6
- "repository": { "type": "git", "url": "git+https://github.com/six5536/smllm.git" },
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/six5536/smllm.git",
9
+ "directory": "packages/smllm"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/six5536/smllm/issues"
13
+ },
14
+ "author": "six5536 <10079653+six5536@users.noreply.github.com>",
15
+ "publishConfig": {
16
+ "registry": "https://registry.npmjs.org",
17
+ "access": "public",
18
+ "provenance": true
19
+ },
20
+ "keywords": [
21
+ "cli",
22
+ "command-line",
23
+ "rust"
24
+ ],
25
+ "bin": {
26
+ "smllm": "bin/smllm.js"
27
+ },
28
+ "files": [
29
+ "bin/",
30
+ "lib/"
31
+ ],
7
32
  "license": "MIT",
8
- "files": ["README.md"],
9
- "publishConfig": { "registry": "https://registry.npmjs.org", "access": "public" }
33
+ "engines": {
34
+ "node": ">=18"
35
+ },
36
+ "optionalDependencies": {
37
+ "@six5536/smllm-linux-x64": "0.4.1",
38
+ "@six5536/smllm-linux-arm64": "0.4.1",
39
+ "@six5536/smllm-darwin-x64": "0.4.1",
40
+ "@six5536/smllm-darwin-arm64": "0.4.1",
41
+ "@six5536/smllm-win32-x64": "0.4.1"
42
+ },
43
+ "scripts": {
44
+ "test": "node --test test/*.test.js"
45
+ }
10
46
  }