forge-cw 0.1.16 → 0.1.17

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-o23w8qWI.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
@@ -2638,6 +2638,20 @@ function readSkill(reader, dir) {
2638
2638
  return null;
2639
2639
  }
2640
2640
  }
2641
+ function readCommands(reader, installPath) {
2642
+ const dir = join8(installPath, "commands");
2643
+ if (!existsSync6(dir))
2644
+ return [];
2645
+ return readdirSync4(dir).filter((f) => f.endsWith(".md")).sort().flatMap((file) => {
2646
+ try {
2647
+ const { frontmatter } = reader.parseFrontmatter(readFileSync6(join8(dir, file), "utf-8"));
2648
+ const hint = frontmatter["argument-hint"];
2649
+ return [{ name: `/${basename2(file, ".md")}`, description: String(frontmatter["description"] ?? ""), ...typeof hint === "string" && hint ? { argumentHint: hint } : {} }];
2650
+ } catch {
2651
+ return [];
2652
+ }
2653
+ });
2654
+ }
2641
2655
  function manifestRepo(manifest) {
2642
2656
  const repo = manifest["repository"];
2643
2657
  if (typeof repo === "string")
@@ -2759,6 +2773,7 @@ async function listPlugins(reader, remoteOf) {
2759
2773
  repo,
2760
2774
  installs: list.map((f) => f.install),
2761
2775
  skills: skillDirs(newest.install.installPath, manifest).flatMap((dir) => readSkill(reader, dir) ?? []),
2776
+ commands: readCommands(reader, newest.install.installPath),
2762
2777
  project: match?.name,
2763
2778
  contributing: match ? existsSync6(join8(match.path, "CONTRIBUTING.md")) : false,
2764
2779
  projectSkills: match ? projectSkillNames(match.path) : []
@@ -3187,6 +3202,10 @@ function ensureSpawnHelperPermissions() {
3187
3202
  } catch {
3188
3203
  }
3189
3204
  }
3205
+ function slashLine(text2) {
3206
+ const line = typeof text2 === "string" ? text2.trim() : "";
3207
+ return line.length <= SLASH_MAX && /^\/[A-Za-z0-9][\w:.-]*( [^\x00-\x1f\x7f]*)?$/.test(line) ? line : null;
3208
+ }
3190
3209
  function buildLaunch(session, isNew) {
3191
3210
  const env = envWithoutHarness();
3192
3211
  const harness = session.harness ?? "claude";
@@ -3255,7 +3274,7 @@ function buildLaunch(session, isNew) {
3255
3274
  cmd += ` --model ${shellQuote(session.model)}`;
3256
3275
  return { command: cmd + harnessFlag, env };
3257
3276
  }
3258
- var SCROLLBACK_LIMIT, IDLE_TIMEOUT_MS, CLEANUP_INTERVAL_MS, shellQuote, PTYManager;
3277
+ var SCROLLBACK_LIMIT, IDLE_TIMEOUT_MS, CLEANUP_INTERVAL_MS, shellQuote, SLASH_MAX, PTYManager;
3259
3278
  var init_pty_manager = __esm({
3260
3279
  "../core/dist/pty-manager.js"() {
3261
3280
  "use strict";
@@ -3266,6 +3285,7 @@ var init_pty_manager = __esm({
3266
3285
  CLEANUP_INTERVAL_MS = 5 * 60 * 1e3;
3267
3286
  shellQuote = (value) => `'${value.replace(/'/g, "'\\''")}'`;
3268
3287
  ensureSpawnHelperPermissions();
3288
+ SLASH_MAX = 300;
3269
3289
  PTYManager = class {
3270
3290
  states;
3271
3291
  sessions = /* @__PURE__ */ new Map();
@@ -6370,7 +6390,7 @@ function readLabs(out, bin) {
6370
6390
  const name = String(l["name"]);
6371
6391
  const enabled = l["enabled"] === true;
6372
6392
  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)])]));
6393
+ 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
6394
  return {
6375
6395
  name,
6376
6396
  title: text(l["title"]) ?? name,
@@ -8517,6 +8537,17 @@ function createForgeServer(options) {
8517
8537
  generalSessions.forget(sessionId);
8518
8538
  return c.json({ ok: true });
8519
8539
  });
8540
+ app.post("/api/cw/terminal/command", async (c) => {
8541
+ const { project, sessionDir, line } = await c.req.json().catch(() => ({}));
8542
+ const command = slashLine(line);
8543
+ if (!project || !sessionDir || !command)
8544
+ return c.json({ error: "project, sessionDir and a slash command on one line are required" }, 400);
8545
+ if (cwReader.getSession(project, sessionDir)?.harness !== "claude")
8546
+ return c.json({ error: "only Claude Code sessions run plugin commands" }, 400);
8547
+ if (!ptyManager.typeLine(project, sessionDir, command))
8548
+ return c.json({ error: "the session has no live terminal" }, 409);
8549
+ return c.json({ ok: true });
8550
+ });
8520
8551
  async function resolveAction(c) {
8521
8552
  const moduleName = c.req.param("module");
8522
8553
  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.17",
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",