motifcode 0.5.0 → 0.5.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
@@ -36,8 +36,13 @@ motif # interactive session in the current dir
36
36
  motif --continue # with the latest conversation here loaded
37
37
  motif "fix the failing test in tests/" # one task, then exit
38
38
  motif -p "what does src/loop.ts do?" # print only the reply, for pipes
39
+ motif -p -- "--help" # pass a flag-looking task literally: -- ends option parsing
39
40
  ```
40
41
 
42
+ A standalone `--` ends flag and subcommand recognition; everything after it is
43
+ the task, so `motif -p -- "--help"` asks about `--help` instead of printing CLI
44
+ help (plain `motif --help` still prints help).
45
+
41
46
  Connect MCP servers and check them from the CLI:
42
47
 
43
48
  ```bash
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.0",
3
- "bytes": 2775935,
2
+ "version": "0.5.1",
3
+ "bytes": 2777079,
4
4
  "node": "v22.23.5"
5
5
  }
package/dist/motif.js CHANGED
@@ -52580,6 +52580,8 @@ var Composer = class {
52580
52580
  browsing = null;
52581
52581
  /** The unsent text set aside while browsing history, restored on the way back. */
52582
52582
  draft = [];
52583
+ /** Cursor position inside that draft, restored with it. */
52584
+ draftCursor = 0;
52583
52585
  get text() {
52584
52586
  return this.chars.join("");
52585
52587
  }
@@ -52731,6 +52733,7 @@ var Composer = class {
52731
52733
  if (this.history.length === 0) return false;
52732
52734
  if (this.browsing === null) {
52733
52735
  this.draft = [...this.chars];
52736
+ this.draftCursor = this.pos;
52734
52737
  this.browsing = this.history.length - 1;
52735
52738
  } else if (this.browsing > 0) {
52736
52739
  this.browsing -= 1;
@@ -52746,11 +52749,12 @@ var Composer = class {
52746
52749
  if (this.browsing < this.history.length - 1) {
52747
52750
  this.browsing += 1;
52748
52751
  this.chars = [...this.history[this.browsing]];
52749
- } else {
52750
- this.browsing = null;
52751
- this.chars = [...this.draft];
52752
+ this.pos = this.chars.length;
52753
+ return true;
52752
52754
  }
52753
- this.pos = this.chars.length;
52755
+ this.browsing = null;
52756
+ this.chars = [...this.draft];
52757
+ this.pos = Math.min(this.draftCursor, this.chars.length);
52754
52758
  return true;
52755
52759
  }
52756
52760
  lineStart(from) {
@@ -53917,9 +53921,13 @@ function attachMention(token, opts) {
53917
53921
  if (rel.startsWith("..") || !existsSync6(target)) return null;
53918
53922
  const st = statSync3(target);
53919
53923
  if (st.isDirectory()) {
53920
- const names = readdirSync3(target).filter((n) => !SKIP_DIRS.has(n)).sort().slice(0, 200);
53924
+ const eligible = readdirSync3(target).filter((n) => !SKIP_DIRS.has(n)).sort();
53925
+ const names = eligible.slice(0, 200);
53926
+ const omitted = eligible.length - names.length;
53927
+ const note2 = omitted > 0 ? `
53928
+ \u2026 ${omitted} more ${omitted === 1 ? "entry" : "entries"}` : "";
53921
53929
  return { mention: clean2, block: `<directory path="${clean2}">
53922
- ${names.join("\n")}
53930
+ ${names.join("\n")}${note2}
53923
53931
  </directory>` };
53924
53932
  }
53925
53933
  const buf = readFileSync6(target);
@@ -54273,11 +54281,24 @@ var COMMANDS = [
54273
54281
  {
54274
54282
  name: "help",
54275
54283
  description: "commands and keys",
54276
- run: () => {
54284
+ usage: "[command]",
54285
+ run: (_ctx, args) => {
54286
+ const requested = args.trim().replace(/^\//, "");
54287
+ if (requested) {
54288
+ const command = findCommand(requested);
54289
+ if (!command) return fail(`/help ${requested}`, `unknown command /${requested} \u2014 /help lists them`);
54290
+ const invocation = `/${command.name}${command.usage ? ` ${command.usage}` : ""}`;
54291
+ return ok(invocation, [
54292
+ command.description,
54293
+ "",
54294
+ "Run /help with no argument for the command index and keys."
54295
+ ]);
54296
+ }
54277
54297
  const width = Math.max(...COMMANDS.map((c) => `/${c.name}${c.usage ? ` ${c.usage}` : ""}`.length));
54278
54298
  const lines = COMMANDS.map(
54279
54299
  (c) => `${`/${c.name}${c.usage ? ` ${c.usage}` : ""}`.padEnd(width)} ${c.description}`
54280
54300
  );
54301
+ lines.push("", "Give /help a command name for its usage: /help <command>.");
54281
54302
  lines.push("", "Skills are commands too: /<skill> [input] runs one \u2014 /skills lists them.");
54282
54303
  const keyWidth = Math.max(...KEYS.map(([k]) => k.length));
54283
54304
  lines.push("", "keys");
@@ -55937,7 +55958,7 @@ function writeFile(path, content, cwd) {
55937
55958
  mkdirSync4(dirname5(target), { recursive: true });
55938
55959
  const existed = existsSync8(target);
55939
55960
  writeFileSync3(target, content, "utf8");
55940
- const lines = content === "" ? 0 : content.split("\n").length;
55961
+ const lines = toLogicalLines(content).length;
55941
55962
  return {
55942
55963
  ok: true,
55943
55964
  output: `${existed ? "replaced" : "created"} ${path} (${lines} lines, ${Buffer.byteLength(content, "utf8")} bytes)`
@@ -63307,7 +63328,7 @@ function pluginConnectionUi(signal) {
63307
63328
  }
63308
63329
 
63309
63330
  // packages/cli/src/main.ts
63310
- var VERSION = "0.5.0";
63331
+ var VERSION = "0.5.1";
63311
63332
  var SHORT_FLAGS = { p: "print", c: "continue", i: "interactive", v: "verbose", h: "help" };
63312
63333
  var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
63313
63334
  "print",
@@ -63328,6 +63349,10 @@ function parseArgs(argv) {
63328
63349
  let command = "run";
63329
63350
  for (let i = 0; i < argv.length; i++) {
63330
63351
  let a = argv[i];
63352
+ if (a === "--") {
63353
+ rest.push(...argv.slice(i + 1));
63354
+ break;
63355
+ }
63331
63356
  if (/^-[a-z]$/.test(a) && SHORT_FLAGS[a.slice(1)]) a = `--${SHORT_FLAGS[a.slice(1)]}`;
63332
63357
  if (a === "--help") {
63333
63358
  if (command === "mcp") flags.help = true;
@@ -63515,6 +63540,7 @@ var HELP = `motif ${VERSION} \u2014 a coding agent built for Motif-3 (unofficial
63515
63540
  motif open the interactive session (a terminal is required)
63516
63541
  motif "<task>" run one task and exit; add --interactive to stay
63517
63542
  motif -p "<question>" print only the final reply, for scripts and pipes (also --print)
63543
+ motif -p -- "--help" treat what follows -- as task text, not flags or subcommands
63518
63544
  motif login paste the selected provider's API key; it is checked and saved to ~/.motif/.env
63519
63545
  motif logout remove the saved key
63520
63546
  motif doctor check the endpoint, the credentials and what the server produces
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motifcode",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "Unofficial coding agent harness built for Motif-3: a Claude Code-style terminal session over the hosted endpoint",
6
6
  "keywords": [