forge-cw 0.1.16 → 0.1.18

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.
@@ -7,7 +7,7 @@
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
8
  <title>Forge Console</title>
9
9
  <script type="importmap">{"imports":{"preact":"/shared/preact.js","preact/hooks":"/shared/preact-hooks.js","preact/jsx-runtime":"/shared/preact-jsx-runtime.js","preact/compat":"/shared/preact-compat.js","@preact/signals":"/shared/preact-signals.js","@forge-dev/ui":"/shared/forge-dev-ui.js","@forge-dev/sdk":"/shared/forge-dev-sdk.js"}}</script>
10
- <script type="module" crossorigin src="/assets/index-DiFbTaPf.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-BRs-GRNk.js"></script>
11
11
  <link rel="stylesheet" crossorigin href="/assets/index-DPf7M8cb.css">
12
12
  <link rel="stylesheet" href="/shared/forge-dev-ui.css">
13
13
  </head>
package/dist/index.js CHANGED
@@ -2630,14 +2630,37 @@ function skillDirs(installPath, manifest) {
2630
2630
  }
2631
2631
  return scanDirs(join8(installPath, "skills"));
2632
2632
  }
2633
- function readSkill(reader, dir) {
2633
+ function readSkill(reader, dir, plugin) {
2634
2634
  try {
2635
2635
  const { frontmatter } = reader.parseFrontmatter(readFileSync6(join8(dir, "SKILL.md"), "utf-8"));
2636
- return { name: String(frontmatter["name"] ?? basename2(dir)), description: String(frontmatter["description"] ?? ""), path: dir };
2636
+ const name = String(frontmatter["name"] ?? basename2(dir));
2637
+ const hint = frontmatter["argument-hint"];
2638
+ const invocable = String(frontmatter["user-invocable"]) !== "false";
2639
+ return {
2640
+ name,
2641
+ description: String(frontmatter["description"] ?? ""),
2642
+ path: dir,
2643
+ ...invocable ? { command: `/${plugin}:${name}` } : {},
2644
+ ...invocable && typeof hint === "string" && hint ? { argumentHint: hint } : {}
2645
+ };
2637
2646
  } catch {
2638
2647
  return null;
2639
2648
  }
2640
2649
  }
2650
+ function readCommands(reader, installPath) {
2651
+ const dir = join8(installPath, "commands");
2652
+ if (!existsSync6(dir))
2653
+ return [];
2654
+ return readdirSync4(dir).filter((f) => f.endsWith(".md")).sort().flatMap((file) => {
2655
+ try {
2656
+ const { frontmatter } = reader.parseFrontmatter(readFileSync6(join8(dir, file), "utf-8"));
2657
+ const hint = frontmatter["argument-hint"];
2658
+ return [{ name: `/${basename2(file, ".md")}`, description: String(frontmatter["description"] ?? ""), ...typeof hint === "string" && hint ? { argumentHint: hint } : {} }];
2659
+ } catch {
2660
+ return [];
2661
+ }
2662
+ });
2663
+ }
2641
2664
  function manifestRepo(manifest) {
2642
2665
  const repo = manifest["repository"];
2643
2666
  if (typeof repo === "string")
@@ -2758,7 +2781,8 @@ async function listPlugins(reader, remoteOf) {
2758
2781
  description: String(manifest["description"] ?? ""),
2759
2782
  repo,
2760
2783
  installs: list.map((f) => f.install),
2761
- skills: skillDirs(newest.install.installPath, manifest).flatMap((dir) => readSkill(reader, dir) ?? []),
2784
+ skills: skillDirs(newest.install.installPath, manifest).flatMap((dir) => readSkill(reader, dir, splitPluginId(id).name) ?? []),
2785
+ commands: readCommands(reader, newest.install.installPath),
2762
2786
  project: match?.name,
2763
2787
  contributing: match ? existsSync6(join8(match.path, "CONTRIBUTING.md")) : false,
2764
2788
  projectSkills: match ? projectSkillNames(match.path) : []
@@ -3187,6 +3211,10 @@ function ensureSpawnHelperPermissions() {
3187
3211
  } catch {
3188
3212
  }
3189
3213
  }
3214
+ function slashLine(text2) {
3215
+ const line = typeof text2 === "string" ? text2.trim() : "";
3216
+ return line.length <= SLASH_MAX && /^\/[A-Za-z0-9][\w:.-]*( [^\x00-\x1f\x7f]*)?$/.test(line) ? line : null;
3217
+ }
3190
3218
  function buildLaunch(session, isNew) {
3191
3219
  const env = envWithoutHarness();
3192
3220
  const harness = session.harness ?? "claude";
@@ -3255,7 +3283,7 @@ function buildLaunch(session, isNew) {
3255
3283
  cmd += ` --model ${shellQuote(session.model)}`;
3256
3284
  return { command: cmd + harnessFlag, env };
3257
3285
  }
3258
- var SCROLLBACK_LIMIT, IDLE_TIMEOUT_MS, CLEANUP_INTERVAL_MS, shellQuote, PTYManager;
3286
+ var SCROLLBACK_LIMIT, IDLE_TIMEOUT_MS, CLEANUP_INTERVAL_MS, shellQuote, SLASH_MAX, PTYManager;
3259
3287
  var init_pty_manager = __esm({
3260
3288
  "../core/dist/pty-manager.js"() {
3261
3289
  "use strict";
@@ -3266,6 +3294,7 @@ var init_pty_manager = __esm({
3266
3294
  CLEANUP_INTERVAL_MS = 5 * 60 * 1e3;
3267
3295
  shellQuote = (value) => `'${value.replace(/'/g, "'\\''")}'`;
3268
3296
  ensureSpawnHelperPermissions();
3297
+ SLASH_MAX = 300;
3269
3298
  PTYManager = class {
3270
3299
  states;
3271
3300
  sessions = /* @__PURE__ */ new Map();
@@ -6370,7 +6399,7 @@ function readLabs(out, bin) {
6370
6399
  const name = String(l["name"]);
6371
6400
  const enabled = l["enabled"] === true;
6372
6401
  const settings = isRecord2(l["settings"]) ? l["settings"] : void 0;
6373
- const set = settings && Object.fromEntries(Object.entries(settings).map(([key, value]) => [key, commandLine(bin, ["config", "set", `labs.${name}.${key}`, typeof value === "string" ? value : JSON.stringify(value)])]));
6402
+ const set = settings && Object.fromEntries(Object.entries(settings).filter(([, value]) => value !== null && value !== void 0).map(([key, value]) => [key, commandLine(bin, ["config", "set", `labs.${name}.${key}`, typeof value === "string" ? value : JSON.stringify(value)])]));
6374
6403
  return {
6375
6404
  name,
6376
6405
  title: text(l["title"]) ?? name,
@@ -8517,6 +8546,17 @@ function createForgeServer(options) {
8517
8546
  generalSessions.forget(sessionId);
8518
8547
  return c.json({ ok: true });
8519
8548
  });
8549
+ app.post("/api/cw/terminal/command", async (c) => {
8550
+ const { project, sessionDir, line } = await c.req.json().catch(() => ({}));
8551
+ const command = slashLine(line);
8552
+ if (!project || !sessionDir || !command)
8553
+ return c.json({ error: "project, sessionDir and a slash command on one line are required" }, 400);
8554
+ if (cwReader.getSession(project, sessionDir)?.harness !== "claude")
8555
+ return c.json({ error: "only Claude Code sessions run plugin commands" }, 400);
8556
+ if (!ptyManager.typeLine(project, sessionDir, command))
8557
+ return c.json({ error: "the session has no live terminal" }, 409);
8558
+ return c.json({ ok: true });
8559
+ });
8520
8560
  async function resolveAction(c) {
8521
8561
  const moduleName = c.req.param("module");
8522
8562
  const actionId = c.req.param("action");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-cw",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "A visual dashboard for your coding agents on Claude Code, Codex, Pi or OpenCode. Installs CW for you.",
5
5
  "license": "MIT",
6
6
  "type": "module",