@skillstate/cli 2.2.1 → 3.0.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 +139 -67
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +13 -32
- package/dist/commands.js.map +1 -1
- package/dist/install.d.ts +104 -72
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +649 -359
- package/dist/install.js.map +1 -1
- package/dist/jsonc.d.ts +42 -0
- package/dist/jsonc.d.ts.map +1 -1
- package/dist/jsonc.js +109 -0
- package/dist/jsonc.js.map +1 -1
- package/package.json +6 -6
package/dist/install.d.ts
CHANGED
|
@@ -7,24 +7,15 @@ export declare const STATE_DIR_NAME = ".skillstate";
|
|
|
7
7
|
export declare const MANIFEST_FILE_NAME = "install-manifest.json";
|
|
8
8
|
/** Parsed `init` flags. */
|
|
9
9
|
export interface InitFlags {
|
|
10
|
-
/** Forced host (`--host`); auto-detected when omitted. */
|
|
11
|
-
host?: HostId;
|
|
12
|
-
/** Non-system messages kept by the plugin (`--max-history`, default 3). */
|
|
13
|
-
maxHistory?: number;
|
|
14
10
|
/** User spec file (`--spec <path>`); overrides the default spec. */
|
|
15
11
|
specPath?: string;
|
|
16
|
-
/** Builtin demo spec (`--example ctf` → InterCode CTF). */
|
|
17
|
-
example?: 'ctf';
|
|
18
|
-
/** Skip MCP server registration (`--no-mcp`). */
|
|
19
|
-
noMcp: boolean;
|
|
20
|
-
/** Skip SKILL.md installation (`--no-skill`). */
|
|
21
|
-
noSkill: boolean;
|
|
22
12
|
/** Print the plan without touching anything (`--dry-run`). */
|
|
23
13
|
dryRun: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
}
|
|
15
|
+
/** Parsed `install` flags (machine-level codex glue). */
|
|
16
|
+
export interface InstallFlags {
|
|
17
|
+
/** Print the plan without touching anything (`--dry-run`). */
|
|
18
|
+
dryRun: boolean;
|
|
28
19
|
}
|
|
29
20
|
/** Parsed `uninstall` flags. */
|
|
30
21
|
export interface UninstallFlags {
|
|
@@ -32,27 +23,55 @@ export interface UninstallFlags {
|
|
|
32
23
|
stateDir?: string;
|
|
33
24
|
/** Also delete the state directory (`--remove-state`). */
|
|
34
25
|
removeState: boolean;
|
|
26
|
+
/** Roll back the machine-level codex glue instead of the project glue (`--machine`). */
|
|
27
|
+
machine: boolean;
|
|
35
28
|
/** Print the plan without touching anything (`--dry-run`). */
|
|
36
29
|
dryRun: boolean;
|
|
37
30
|
}
|
|
38
|
-
/**
|
|
31
|
+
/** Per-host glue recorded by a project install (manifest v2). */
|
|
39
32
|
export interface InstallManifest {
|
|
40
|
-
version:
|
|
41
|
-
host: HostId;
|
|
33
|
+
version: 2;
|
|
42
34
|
installedAt: string;
|
|
35
|
+
/** Absolute path of the created/used state envelope. */
|
|
43
36
|
statePath: string;
|
|
44
|
-
|
|
45
|
-
pluginPath?: string;
|
|
37
|
+
/** Absolute path of the host-neutral SKILL.md (when opencode/claude wired). */
|
|
46
38
|
skillPath?: string;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
hosts: {
|
|
40
|
+
opencode?: {
|
|
41
|
+
/** The project `opencode.jsonc|json` carrying the v2 `plugins` entry. */
|
|
42
|
+
config: {
|
|
43
|
+
configPath: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Legacy v1 record (the MCP registration). Only ever READ, so a
|
|
47
|
+
* project initialised before the native-tools rewrite can still be
|
|
48
|
+
* uninstalled; a fresh install never writes it.
|
|
49
|
+
*/
|
|
50
|
+
mcp?: {
|
|
51
|
+
configPath: string;
|
|
52
|
+
format: 'opencode-json';
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
claude?: {
|
|
56
|
+
hooks: {
|
|
57
|
+
configPath: string;
|
|
58
|
+
scriptDir: string;
|
|
59
|
+
};
|
|
60
|
+
mcp: {
|
|
61
|
+
configPath: string;
|
|
62
|
+
format: 'claude-mcp-json';
|
|
63
|
+
};
|
|
64
|
+
};
|
|
52
65
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
}
|
|
67
|
+
/** Codex machine-level install record (`<home>/.skillstate/install-manifest.json`). */
|
|
68
|
+
export interface MachineInstallManifest {
|
|
69
|
+
version: 1;
|
|
70
|
+
installedAt: string;
|
|
71
|
+
codex: {
|
|
72
|
+
hooksConfigPath: string;
|
|
73
|
+
scriptDir: string;
|
|
74
|
+
tomlConfigPath: string;
|
|
56
75
|
};
|
|
57
76
|
}
|
|
58
77
|
/** Default home (`$HOME`, else `os.homedir()`); the `main` entry uses this. */
|
|
@@ -60,67 +79,56 @@ export declare function defaultHome(): string;
|
|
|
60
79
|
/** True when `dir` resolves inside the system temp directory (`os.tmpdir()`). */
|
|
61
80
|
export declare function isInsideTemp(dir: string): boolean;
|
|
62
81
|
/**
|
|
63
|
-
* Detect
|
|
82
|
+
* Detect ALL supported hosts from marker files under `home`, in fixed order
|
|
83
|
+
* [opencode, claude, codex]:
|
|
64
84
|
* - opencode: `~/.config/opencode/opencode.jsonc|opencode.json` or `~/.opencode/bin/opencode`;
|
|
65
85
|
* - claude: `~/.claude`;
|
|
66
86
|
* - codex: `~/.codex`.
|
|
67
|
-
* Returns
|
|
87
|
+
* Returns every match (empty when nothing does) — init wires them all at once.
|
|
68
88
|
*/
|
|
69
|
-
export declare function
|
|
89
|
+
export declare function detectHosts(home: string): HostId[];
|
|
70
90
|
/**
|
|
71
|
-
* Parse `init` flags: `--
|
|
72
|
-
* `--no-skill`, `--dry-run`, `--auto`, `--uninstall` (`=`-forms accepted).
|
|
91
|
+
* Parse `init` flags: `--spec <path>` (or `--spec=<path>`), `--dry-run`.
|
|
73
92
|
* Throws an `Error` with the usage line on unknown/invalid flags.
|
|
74
93
|
*/
|
|
75
94
|
export declare function parseInitArgs(args: string[]): InitFlags;
|
|
95
|
+
/**
|
|
96
|
+
* Parse `install` flags: `--dry-run` only (the command wires the machine-
|
|
97
|
+
* level codex glue; project wiring belongs to `init`).
|
|
98
|
+
*/
|
|
99
|
+
export declare function parseInstallArgs(args: string[]): InstallFlags;
|
|
76
100
|
/**
|
|
77
101
|
* Parse `uninstall` flags: `--state-dir <path>`, `--remove-state`,
|
|
78
|
-
* `--dry-run`. Throws an `Error` with the usage line on
|
|
102
|
+
* `--machine`, `--dry-run`. Throws an `Error` with the usage line on
|
|
103
|
+
* unknown flags.
|
|
79
104
|
*/
|
|
80
105
|
export declare function parseUninstallArgs(args: string[]): UninstallFlags;
|
|
81
|
-
/** Thrown by `parseInitArgs`/`parseUninstallArgs` on `--help`/`-h`. */
|
|
106
|
+
/** Thrown by `parseInitArgs`/`parseInstallArgs`/`parseUninstallArgs` on `--help`/`-h`. */
|
|
82
107
|
export declare class HelpRequestedInitError extends Error {
|
|
83
108
|
constructor();
|
|
84
109
|
}
|
|
85
|
-
/** Usage line for init/uninstall (composed with the CLI usage in commands.ts). */
|
|
86
|
-
export declare const CLI_USAGE_INSTALL = "Usage: skillstate init [--
|
|
87
|
-
/** Resolve the MCP server command: the `@skillstate/mcp` bin via `node`, or the global `skillstate-mcp` bin. */
|
|
88
|
-
export declare function resolveMcpCommandWith(resolve: (id: string) => string): {
|
|
89
|
-
command: string;
|
|
90
|
-
args: string[];
|
|
91
|
-
};
|
|
92
|
-
/** `resolveMcpCommandWith` bound to this module's require resolver. */
|
|
93
|
-
export declare function resolveMcpCommand(): {
|
|
94
|
-
command: string;
|
|
95
|
-
args: string[];
|
|
96
|
-
};
|
|
110
|
+
/** Usage line for init/install/uninstall (composed with the CLI usage in commands.ts). */
|
|
111
|
+
export declare const CLI_USAGE_INSTALL = "Usage: skillstate init [--spec <path>] [--dry-run] | install [--dry-run] | uninstall [--state-dir <path>] [--remove-state] [--machine] [--dry-run]";
|
|
97
112
|
/**
|
|
98
|
-
* Spec resolution for `init`: `--spec <path>` wins (validated),
|
|
99
|
-
*
|
|
100
|
-
*
|
|
113
|
+
* Spec resolution for `init`: `--spec <path>` wins (validated), else the
|
|
114
|
+
* neutral domain-agnostic default. Never defaults to a domain-specific
|
|
115
|
+
* example.
|
|
101
116
|
*/
|
|
102
117
|
export declare function resolveInitSpec(cwd: string, flags: InitFlags): ProceduralSpec;
|
|
103
|
-
/** SKILL.md with a short frontmatter description + the adapter-generated body. */
|
|
104
|
-
export declare function buildSkillMd(statePathRel: string, spec: ProceduralSpec, host?: HostId): string;
|
|
105
118
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
119
|
+
* Host-neutral SKILL.md: ONE file (`<cwd>/.claude/skills/skillstate/`)
|
|
120
|
+
* serves opencode AND claude (opencode reads project `.claude/skills/`
|
|
121
|
+
* too). The body names no host-specific hook/plugin events — the harness
|
|
122
|
+
* integration (npm plugin for opencode, hooks for claude) injects the
|
|
123
|
+
* current state into context every turn, and everything else goes through
|
|
124
|
+
* the host-agnostic skillstate MCP tools.
|
|
109
125
|
*/
|
|
126
|
+
export declare function buildSkillMd(spec: ProceduralSpec): string;
|
|
127
|
+
/** Skillstate MCP entry shaped like OpenCode's local-server entries (`npx @skillstate/mcp`). */
|
|
110
128
|
export declare function buildMcpEntry(): Record<string, unknown>;
|
|
111
|
-
/**
|
|
112
|
-
* Claude Code `.mcp.json` entry (2.1.260 wire format: `type: "stdio"`,
|
|
113
|
-
* `command` is a string, args go to the separate `args` array). No
|
|
114
|
-
* environment is written — the server resolves the per-project state from
|
|
115
|
-
* its own cwd at startup.
|
|
116
|
-
*/
|
|
129
|
+
/** Claude Code `.mcp.json` entry (stdio wire format, `npx @skillstate/mcp`). */
|
|
117
130
|
export declare function buildClaudeMcpEntry(): Record<string, unknown>;
|
|
118
|
-
/**
|
|
119
|
-
* `[mcp_servers.skillstate]` TOML block for `~/.codex/config.toml` (codex
|
|
120
|
-
* 0.142 wire format: `command` is a string, args go to the separate `args`
|
|
121
|
-
* array). The server resolves the per-project state from the session cwd,
|
|
122
|
-
* so no `SKILLSTATE_STATE_PATH` is pinned.
|
|
123
|
-
*/
|
|
131
|
+
/** `[mcp_servers.skillstate]` TOML block for `~/.codex/config.toml` (`npx @skillstate/mcp`). */
|
|
124
132
|
export declare function buildCodexMcpToml(): string;
|
|
125
133
|
/**
|
|
126
134
|
* Splice the `skillstate` server into the `mcp` object of OpenCode config
|
|
@@ -143,24 +151,48 @@ export interface InstallOptions {
|
|
|
143
151
|
cwd: string;
|
|
144
152
|
home: string;
|
|
145
153
|
flags: InitFlags;
|
|
146
|
-
/**
|
|
154
|
+
/** Programmatic host override (tests); defaults to `detectHosts(home)`. */
|
|
155
|
+
hosts?: HostId[];
|
|
156
|
+
/** Spec override; defaults to `resolveInitSpec(cwd, flags)`. */
|
|
147
157
|
spec?: ProceduralSpec;
|
|
148
158
|
}
|
|
149
159
|
/**
|
|
150
|
-
* Full one-shot
|
|
160
|
+
* Full one-shot project wiring for EVERY detected host. Never throws for
|
|
151
161
|
* expected conditions; returns a process exit code (0 ok, 1 no host).
|
|
152
162
|
*/
|
|
153
163
|
export declare function autoInstall(options: InstallOptions): Promise<number>;
|
|
164
|
+
/**
|
|
165
|
+
* Options for {@link installMachine}: wire the machine-level codex glue
|
|
166
|
+
* under `home`.
|
|
167
|
+
*/
|
|
168
|
+
export interface MachineInstallOptions {
|
|
169
|
+
home: string;
|
|
170
|
+
flags: InstallFlags;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Machine-level install (`skillstate install`): codex ONLY. Writes the
|
|
174
|
+
* self-contained `.cjs` hook scripts into `~/.codex/hooks/skillstate/`,
|
|
175
|
+
* merges the skillstate hook groups into `~/.codex/hooks.json`, and appends
|
|
176
|
+
* the `[mcp_servers.skillstate]` table to `~/.codex/config.toml`. Every
|
|
177
|
+
* script resolves the per-project state from the session cwd, so one
|
|
178
|
+
* machine install serves every project. Idempotent (re-merging hooks is a
|
|
179
|
+
* no-op; the TOML table is appended only when absent). opencode/claude glue
|
|
180
|
+
* is project-local and belongs to `skillstate init`. Returns a process exit
|
|
181
|
+
* code (always 0).
|
|
182
|
+
*/
|
|
183
|
+
export declare function installMachine(options: MachineInstallOptions): Promise<number>;
|
|
154
184
|
/** Options for {@link uninstall}. */
|
|
155
185
|
export interface UninstallOptions {
|
|
156
186
|
cwd: string;
|
|
187
|
+
home: string;
|
|
157
188
|
flags: UninstallFlags;
|
|
158
189
|
}
|
|
159
190
|
/**
|
|
160
|
-
* Roll back exactly what an install recorded in the manifest:
|
|
161
|
-
*
|
|
162
|
-
* the
|
|
163
|
-
*
|
|
191
|
+
* Roll back exactly what an install recorded in the manifest: project glue
|
|
192
|
+
* per host record (opencode config splices, claude hooks + scripts + mcp,
|
|
193
|
+
* the shared SKILL.md), and optionally the whole state directory. With
|
|
194
|
+
* `--machine`, rolls the machine-level codex glue back instead. Returns a
|
|
195
|
+
* process exit code (0 ok, 1 no/corrupt manifest).
|
|
164
196
|
*/
|
|
165
197
|
export declare function uninstall(options: UninstallOptions): Promise<number>;
|
|
166
198
|
//# sourceMappingURL=install.d.ts.map
|
package/dist/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAevD,uBAAuB;AACvB,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErD,iDAAiD;AACjD,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C,uDAAuD;AACvD,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAU1D,2BAA2B;AAC3B,MAAM,WAAW,SAAS;IACxB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,MAAM,EAAE,OAAO,CAAC;CACjB;AAED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