wordspace 0.0.12 → 0.0.14

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.
@@ -1 +1,6 @@
1
- export declare function run(target: string | undefined, force: boolean, harnessArg?: string): Promise<void>;
1
+ export interface RunOptions {
2
+ params?: Record<string, string>;
3
+ skillsDir?: string;
4
+ model?: string;
5
+ }
6
+ export declare function run(target: string | undefined, force: boolean, harnessArg?: string, options?: RunOptions): Promise<void>;
@@ -5,6 +5,7 @@ import { httpGet, getAuthHeaders } from "../lib/workflows.js";
5
5
  import { HARNESSES, detectInstalled, spawnHarness, } from "../lib/harness.js";
6
6
  import { pickOne } from "../lib/prompt.js";
7
7
  import { ensureInit } from "../steps/auto-init.js";
8
+ import { discoverSkills } from "../lib/skills.js";
8
9
  import * as log from "../lib/log.js";
9
10
  /**
10
11
  * Build the prompt string for a given harness.
@@ -12,22 +13,58 @@ import * as log from "../lib/log.js";
12
13
  * Skill-native harnesses (Claude Code) get the short `/open-prose run <path>` command.
13
14
  * All others receive the .prose file content inline with execution instructions.
14
15
  */
15
- function buildPrompt(harness, prosePath, cwd) {
16
+ function buildPrompt(harness, prosePath, cwd, params) {
16
17
  if (harness.skillNative) {
18
+ if (params && Object.keys(params).length > 0) {
19
+ return `/open-prose run ${prosePath} --params '${JSON.stringify(params)}'`;
20
+ }
17
21
  return `/open-prose run ${prosePath}`;
18
22
  }
19
23
  const fullPath = join(cwd, prosePath);
20
24
  const content = readFileSync(fullPath, "utf-8");
21
- return [
25
+ const lines = [
22
26
  `You are executing a wordspace workflow defined in the file "${prosePath}".`,
23
27
  `Follow the steps below exactly. Write all output files to the "output/" directory.`,
24
- "",
25
- "--- BEGIN WORKFLOW ---",
26
- content,
27
- "--- END WORKFLOW ---",
28
- ].join("\n");
28
+ ];
29
+ if (params && Object.keys(params).length > 0) {
30
+ lines.push("", "The following input parameters have been provided:");
31
+ for (const [key, value] of Object.entries(params)) {
32
+ lines.push(` ${key} = "${value}"`);
33
+ }
34
+ lines.push("Use these values for the corresponding `input` declarations in the workflow.");
35
+ }
36
+ lines.push("", "--- BEGIN WORKFLOW ---", content, "--- END WORKFLOW ---");
37
+ return lines.join("\n");
38
+ }
39
+ /**
40
+ * Build a rich passthrough prompt that tells the calling agent where skills
41
+ * are installed, how to use open-prose, and provides workflow params.
42
+ */
43
+ function buildPassthroughPrompt(prosePath, cwd, params, skillsDir) {
44
+ const fullPath = join(cwd, prosePath);
45
+ const content = readFileSync(fullPath, "utf-8");
46
+ const discovery = discoverSkills(cwd, skillsDir);
47
+ const lines = [];
48
+ if (discovery) {
49
+ const skillList = discovery.skills
50
+ .map((s) => ` - ${s.name}`)
51
+ .join("\n");
52
+ lines.push(`You have access to the following skills installed at ${discovery.dir}:`, skillList, "", "To execute this workflow:", "", `1. Read the open-prose skill: ${discovery.dir}/open-prose/SKILL.md`, "2. Follow its instructions to load the VM (prose.md) and become the OpenProse interpreter", `3. Run the workflow file: ${prosePath}`);
53
+ }
54
+ else {
55
+ lines.push(`You are executing a wordspace workflow defined in the file "${prosePath}".`, `Follow the steps below exactly. Write all output files to the "output/" directory.`);
56
+ }
57
+ if (params && Object.keys(params).length > 0) {
58
+ lines.push("", "The following input parameters have been provided:");
59
+ for (const [key, value] of Object.entries(params)) {
60
+ lines.push(` ${key} = "${value}"`);
61
+ }
62
+ lines.push("Use these values for the corresponding `input` declarations in the workflow.");
63
+ }
64
+ lines.push("", `--- WORKFLOW: ${prosePath} ---`, content, "--- END WORKFLOW ---");
65
+ return lines.join("\n");
29
66
  }
30
- export async function run(target, force, harnessArg) {
67
+ export async function run(target, force, harnessArg, options) {
31
68
  if (!target) {
32
69
  log.error("Usage: wordspace run <github:owner/repo/path.prose | local-path>");
33
70
  process.exit(1);
@@ -86,7 +123,7 @@ export async function run(target, force, harnessArg) {
86
123
  }
87
124
  const cwd = process.cwd();
88
125
  // Auto-init if needed (harness-aware)
89
- ensureInit(cwd, harness);
126
+ ensureInit(cwd, harness, options?.skillsDir);
90
127
  let prosePath;
91
128
  if (target.startsWith("github:")) {
92
129
  // Remote: download from GitHub
@@ -116,12 +153,12 @@ export async function run(target, force, harnessArg) {
116
153
  }
117
154
  prosePath = target;
118
155
  }
119
- const prompt = buildPrompt(harness, prosePath, cwd);
120
156
  if (harness.mode === "passthrough") {
121
- // The calling agent is already running — just output the prompt
122
- console.log(prompt);
157
+ const passthroughPrompt = buildPassthroughPrompt(prosePath, cwd, options?.params, options?.skillsDir);
158
+ console.log(passthroughPrompt);
123
159
  process.exit(0);
124
160
  }
161
+ const prompt = buildPrompt(harness, prosePath, cwd, options?.params);
125
162
  console.log();
126
163
  if (harness.skillNative) {
127
164
  log.info(prompt);
@@ -130,6 +167,6 @@ export async function run(target, force, harnessArg) {
130
167
  log.info(`Running ${prosePath} via ${harness.name}...`);
131
168
  }
132
169
  console.log();
133
- const exitCode = spawnHarness(harness, prompt, cwd);
170
+ const exitCode = spawnHarness(harness, prompt, cwd, options?.model);
134
171
  process.exit(exitCode);
135
172
  }
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { search } from "./commands/search.js";
4
4
  import { add } from "./commands/add.js";
5
5
  import { run } from "./commands/run.js";
6
6
  import * as log from "./lib/log.js";
7
- const VERSION = "0.0.12";
7
+ const VERSION = "0.0.14";
8
8
  const HELP = `
9
9
  Usage: wordspace <command> [options]
10
10
 
@@ -17,6 +17,9 @@ Commands:
17
17
  Options:
18
18
  --force Re-run all steps / overwrite existing files
19
19
  --harness <name> Use a specific coding agent (e.g. claude, aider, goose)
20
+ --model <model> Model to pass to the harness (e.g. openrouter/minimax/minimax-m2.5)
21
+ --params <json> Workflow input parameters as JSON (e.g. '{"topic":"x402"}')
22
+ --skills-dir <dir> Custom skills directory (default: auto-discover)
20
23
  --help Show this help message
21
24
  --version Show version number
22
25
  `.trim();
@@ -30,13 +33,31 @@ async function main() {
30
33
  console.log(VERSION);
31
34
  process.exit(0);
32
35
  }
33
- const harnessIdx = args.indexOf("--harness");
34
- const harnessArg = harnessIdx !== -1 ? args[harnessIdx + 1] : undefined;
36
+ let harnessArg;
37
+ let modelArg;
38
+ let params;
39
+ let skillsDir;
35
40
  // Filter out flags and their values from positional args
36
41
  const positional = [];
37
42
  for (let i = 0; i < args.length; i++) {
38
43
  if (args[i] === "--harness") {
39
- i++; // skip the value
44
+ harnessArg = args[++i];
45
+ }
46
+ else if (args[i] === "--model") {
47
+ modelArg = args[++i];
48
+ }
49
+ else if (args[i] === "--params") {
50
+ const raw = args[++i];
51
+ try {
52
+ params = JSON.parse(raw);
53
+ }
54
+ catch {
55
+ log.error("Invalid --params JSON");
56
+ process.exit(1);
57
+ }
58
+ }
59
+ else if (args[i] === "--skills-dir") {
60
+ skillsDir = args[++i];
40
61
  }
41
62
  else if (!args[i].startsWith("-")) {
42
63
  positional.push(args[i]);
@@ -54,7 +75,7 @@ async function main() {
54
75
  await add(positional.slice(1), force);
55
76
  }
56
77
  else if (command === "run") {
57
- await run(positional[1], force, harnessArg);
78
+ await run(positional[1], force, harnessArg, { params, skillsDir, model: modelArg });
58
79
  }
59
80
  else if (!command) {
60
81
  console.log(HELP);
@@ -3,8 +3,8 @@ export interface Harness {
3
3
  name: string;
4
4
  /** Binary name on PATH. */
5
5
  bin: string;
6
- /** Build the CLI args from the prompt string. */
7
- args: (prompt: string) => string[];
6
+ /** Build the CLI args from the prompt string and optional model. */
7
+ args: (prompt: string, model?: string) => string[];
8
8
  /** URL or install command the user can use to install this harness. */
9
9
  installUrl: string;
10
10
  /** Whether the harness runs interactively, headless, or passthrough (already running). */
@@ -17,4 +17,4 @@ export declare const HARNESSES: Harness[];
17
17
  /** Return only the harnesses whose binary is found on PATH. */
18
18
  export declare function detectInstalled(): Harness[];
19
19
  /** Spawn a harness interactively, handing over the terminal. */
20
- export declare function spawnHarness(harness: Harness, prompt: string, cwd: string): number;
20
+ export declare function spawnHarness(harness: Harness, prompt: string, cwd: string, model?: string): number;
@@ -44,9 +44,13 @@ export const HARNESSES = [
44
44
  {
45
45
  name: "OpenCode",
46
46
  bin: "opencode",
47
- args: (prompt) => ["--prompt", prompt],
47
+ args: (prompt, model) => [
48
+ "run",
49
+ "--prompt", prompt,
50
+ ...(model ? ["--model", model] : []),
51
+ ],
48
52
  installUrl: "https://opencode.ai",
49
- mode: "interactive",
53
+ mode: "headless",
50
54
  skillNative: false,
51
55
  },
52
56
  {
@@ -103,8 +107,8 @@ export function detectInstalled() {
103
107
  });
104
108
  }
105
109
  /** Spawn a harness interactively, handing over the terminal. */
106
- export function spawnHarness(harness, prompt, cwd) {
107
- const result = spawnSync(harness.bin, harness.args(prompt), {
110
+ export function spawnHarness(harness, prompt, cwd, model) {
111
+ const result = spawnSync(harness.bin, harness.args(prompt, model), {
108
112
  cwd,
109
113
  stdio: "inherit",
110
114
  });
@@ -0,0 +1,20 @@
1
+ export interface SkillInfo {
2
+ name: string;
3
+ path: string;
4
+ }
5
+ export interface SkillDiscoveryResult {
6
+ dir: string;
7
+ skills: SkillInfo[];
8
+ }
9
+ /**
10
+ * Discover installed skills by checking directories in priority order:
11
+ * 1. customDir (if --skills-dir provided)
12
+ * 2. <cwd>/.agents/skills/
13
+ * 3. ~/.agents/skills/ (home dir global)
14
+ *
15
+ * Returns the first directory that contains at least the open-prose skill.
16
+ * Lists all skills found in that directory (each subdirectory with a SKILL.md).
17
+ */
18
+ export declare function discoverSkills(cwd: string, customDir?: string): SkillDiscoveryResult | null;
19
+ /** Check whether the required skills are installed in a given directory. */
20
+ export declare function hasRequiredSkills(dir: string): boolean;
@@ -0,0 +1,44 @@
1
+ import { existsSync, readdirSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { homedir } from "node:os";
4
+ /**
5
+ * Discover installed skills by checking directories in priority order:
6
+ * 1. customDir (if --skills-dir provided)
7
+ * 2. <cwd>/.agents/skills/
8
+ * 3. ~/.agents/skills/ (home dir global)
9
+ *
10
+ * Returns the first directory that contains at least the open-prose skill.
11
+ * Lists all skills found in that directory (each subdirectory with a SKILL.md).
12
+ */
13
+ export function discoverSkills(cwd, customDir) {
14
+ const candidates = [];
15
+ if (customDir)
16
+ candidates.push(customDir);
17
+ candidates.push(join(cwd, ".agents", "skills"));
18
+ candidates.push(join(homedir(), ".agents", "skills"));
19
+ for (const dir of candidates) {
20
+ if (!existsSync(dir))
21
+ continue;
22
+ const hasOpenProse = existsSync(join(dir, "open-prose"));
23
+ if (!hasOpenProse)
24
+ continue;
25
+ const skills = [];
26
+ for (const entry of readdirSync(dir)) {
27
+ const entryPath = join(dir, entry);
28
+ if (!statSync(entryPath).isDirectory())
29
+ continue;
30
+ if (existsSync(join(entryPath, "SKILL.md"))) {
31
+ skills.push({ name: entry, path: entryPath });
32
+ }
33
+ }
34
+ if (skills.length > 0) {
35
+ return { dir, skills };
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+ /** Check whether the required skills are installed in a given directory. */
41
+ export function hasRequiredSkills(dir) {
42
+ const required = ["open-prose", "agentwallet", "registry", "wordspace"];
43
+ return required.every((s) => existsSync(join(dir, s)));
44
+ }
@@ -1,3 +1,3 @@
1
1
  import type { Harness } from "../lib/harness.js";
2
2
  /** Silently initialize the project if not already done. */
3
- export declare function ensureInit(cwd: string, harness: Harness): void;
3
+ export declare function ensureInit(cwd: string, harness: Harness, customSkillsDir?: string): void;
@@ -3,6 +3,7 @@ import { execSync } from "node:child_process";
3
3
  import { join } from "node:path";
4
4
  import { setupClaude } from "./setup-claude.js";
5
5
  import { createDirs } from "./create-dirs.js";
6
+ import { discoverSkills, hasRequiredSkills } from "../lib/skills.js";
6
7
  import * as log from "../lib/log.js";
7
8
  const SKILL_PACKAGES = [
8
9
  "frames-engineering/skills",
@@ -22,17 +23,14 @@ function installSkills(cwd) {
22
23
  }
23
24
  }
24
25
  /** Silently initialize the project if not already done. */
25
- export function ensureInit(cwd, harness) {
26
+ export function ensureInit(cwd, harness, customSkillsDir) {
26
27
  const isClaude = harness.bin === "claude";
27
28
  const hasSettings = isClaude
28
29
  ? existsSync(join(cwd, ".claude", "settings.local.json"))
29
30
  : true; // non-Claude harnesses don't need Claude settings
30
31
  const hasOutput = existsSync(join(cwd, "output"));
31
- const skillsDir = join(cwd, ".agents", "skills");
32
- const hasSkills = existsSync(join(skillsDir, "open-prose")) &&
33
- existsSync(join(skillsDir, "agentwallet")) &&
34
- existsSync(join(skillsDir, "registry")) &&
35
- existsSync(join(skillsDir, "wordspace"));
32
+ const discovery = discoverSkills(cwd, customSkillsDir);
33
+ const hasSkills = discovery !== null && hasRequiredSkills(discovery.dir);
36
34
  if (hasSettings && hasOutput && hasSkills)
37
35
  return;
38
36
  log.info("Auto-initializing project...");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wordspace",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"