@minhpnq1807/contextos 0.5.5 → 0.5.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.7
4
+
5
+ - Adds thin passthrough commands `ctx ruler -- <args>` and `ctx skillshare -- <args>` for upstream admin/debug workflows without reimplementing those CLIs.
6
+ - Preserves upstream output and exit status for passthrough commands, with install hints when the upstream binary is missing.
7
+
8
+ ## 0.5.6
9
+
10
+ - Adds visible `ctx install` progress from 0-100 so long model/file/skill embedding warmups no longer look stalled.
11
+ - Accepts `agy` as the Antigravity alias for install, Ruler sync, and skillshare sync while still passing Ruler/skillshare their official `antigravity` agent id.
12
+ - Makes `ctx install --inject` explicitly override `--quiet` when both flags are present.
13
+
3
14
  ## 0.5.5
4
15
 
5
16
  - Discovers all skill roots containing `SKILL.md` under global/project `.gemini`, `.codex`, and `.claude` directories before `ctx sync --skills`.
package/README.md CHANGED
@@ -162,6 +162,8 @@ Restart Antigravity or `agy` after installing.
162
162
 
163
163
  The embedding model is mandatory. `ctx install` checks `~/.ctx/contextos/models` first and downloads the MiniLM model only when the required local files are missing. It intentionally fails if the model cannot be prepared, because otherwise the first prompt hook would have to cold-load or download the model.
164
164
 
165
+ During install, ContextOS prints a 0-100 progress indicator. The longest stage is usually embedding warmup; if the model is already cached, install skips the download and only refreshes vectors.
166
+
165
167
  Verify the published package in any project:
166
168
 
167
169
  ```bash
@@ -191,6 +193,7 @@ Useful variants:
191
193
  ctx sync --skills --dry-run
192
194
  ctx sync --skills --no-collect
193
195
  ctx sync --skills --agents codex,claude
196
+ ctx sync --skills --agents codex,claude,agy
194
197
  ```
195
198
 
196
199
  After this, `ctx debug -- "task"` and prompt hooks can suggest skills from `~/.config/skillshare/skills/` plus agent-specific skill folders.
@@ -235,11 +238,13 @@ Use Ruler when the project wants one rule/MCP source of truth for multiple agent
235
238
  ctx sync --rules
236
239
  ```
237
240
 
238
- Default agents are `codex`, `claude`, and `antigravity`. You can target a subset:
241
+ Default agents are `codex`, `claude`, and `agy` (Antigravity). Ruler's official identifier is still `antigravity`, so ContextOS accepts both `agy` and `antigravity` and normalizes them before calling Ruler. You can target a subset:
239
242
 
240
243
  ```bash
241
244
  ctx sync --rules --agents codex
242
245
  ctx sync --rules --agents codex,claude
246
+ ctx sync --rules --agents codex,claude,agy
247
+ ctx sync --rules --agents codex,claude,antigravity
243
248
  ```
244
249
 
245
250
  What it does:
@@ -264,6 +269,20 @@ ctx sync --rules --no-import-codex-mcp
264
269
 
265
270
  `ctx sync --rules` is project-scoped. It writes `.ruler/ruler.toml` in the current project and lets Ruler generate agent files from that project source of truth. ContextOS runtime history still follows the project-path isolation model described below.
266
271
 
272
+ ## Upstream Passthrough
273
+
274
+ ContextOS exposes thin passthrough commands for Ruler and skillshare admin/debug workflows:
275
+
276
+ ```bash
277
+ ctx ruler -- apply --agents codex,claude,antigravity
278
+ ctx ruler -- init
279
+ ctx skillshare -- status
280
+ ctx skillshare -- target list
281
+ ctx skillshare -- doctor
282
+ ```
283
+
284
+ Everything after `--` is forwarded unchanged to the upstream CLI. ContextOS does not reinterpret those args, and it preserves the upstream output and exit status. Use `ctx sync --rules` and `ctx sync --skills` for ContextOS-managed workflows; use passthrough when you need a native Ruler or skillshare command.
285
+
267
286
  ## Troubleshooting
268
287
 
269
288
  ### `ctx-mcp bridge socket not found`
@@ -302,7 +321,7 @@ This warning comes from a transitive dependency in the local embedding/WASM stac
302
321
  | `ctx install agy` | Installs ContextOS into Antigravity. | You use the `agy` CLI or Antigravity app/editor. | Copies a stable package root to `~/.ctx/contextos/agents/agy/contextos`, writes hooks to `~/.gemini/config/hooks.json`, and registers `ctx-mcp` in Antigravity app, CLI, and legacy editor MCP config paths. |
303
322
  | `ctx install --agent <name>` | Installs for a named agent. | You prefer explicit scripts. | Accepts `codex`, `claude`, or `agy`. |
304
323
  | `ctx install --quiet` | Installs ContextOS in measurement-only mode. | You want reports and stats but do not want visible injected context. | Installs the same hooks, but prompt hooks return empty context. |
305
- | `ctx install --inject` | Installs ContextOS with explicit injection mode. | You want to be explicit in scripts or docs. | Same runtime behavior as the default install mode. |
324
+ | `ctx install --inject` | Installs ContextOS with explicit injection mode. | You want to be explicit in scripts or docs. | Same runtime behavior as the default install mode; if combined with `--quiet`, `--inject` wins. |
306
325
  | `ctx install --copy` | Copies only the plugin payload to `$CODEX_HOME/plugins/ctx`. | Local development or manual plugin experiments. | Does not register marketplace, MCP, or global hooks. |
307
326
  | `ctx debug -- "task"` | Runs the scheduler locally for a fake prompt. | You want to see which AGENTS.md rules and files ContextOS would inject before using Codex. | Prints rule scores, scoring reasons, suggested files, and final `additionalContext`. |
308
327
  | `ctx report` | Shows the last Stop-hook compliance report for the current workspace. | An agent task has finished and you want the summary again. | Reads `~/.ctx/contextos/workspaces/<workspace-id>/last-report.json`. |
@@ -310,15 +329,17 @@ This warning comes from a transitive dependency in the local embedding/WASM stac
310
329
  | `ctx stats` | Shows aggregate runtime metrics for the current workspace. | You want to know whether ContextOS is active and useful over time. | Prints prompt count, report count, injected/quiet ratio, average prompt analysis time, efficiency, rule outcomes, hook events, and last suggested files for the current workspace only. |
311
330
  | `ctx benchmark -- "task"` | Compares baseline AGENTS.md ordering with ContextOS task-aware scheduling. | You want a before/after signal for lost-in-the-middle risk. | Prints parsed/actionable/filtered rule counts, relevant rules in the middle of the original file, scheduled high/mid rules, and top scored rules. |
312
331
  | `ctx sync --rules` | Syncs project rules and MCP servers through Ruler. | You want Codex, Claude Code, and Antigravity to share one project rule/MCP source of truth. | Ensures `.ruler/ruler.toml`, injects `ctx-mcp`, imports existing MCP servers from Codex and project `.mcp.json`, runs `ruler apply --agents codex,claude,antigravity`, mirrors MCP servers to Antigravity MCP configs, and verifies generated config. |
313
- | `ctx sync --rules --agents <list>` | Syncs only selected agents through Ruler. | You want to update one or two agents without touching the others. | Accepts comma-separated values such as `codex`, `claude`, `antigravity`, or `codex,claude`. |
332
+ | `ctx sync --rules --agents <list>` | Syncs only selected agents through Ruler. | You want to update one or two agents without touching the others. | Accepts comma-separated values such as `codex`, `claude`, `agy`, `antigravity`, or `codex,claude,agy`; `agy` is normalized to Ruler's `antigravity`. |
314
333
  | `ctx sync --rules --dry-run` | Previews Ruler sync without writing files or running apply. | You want to inspect behavior before changing project config. | Prints the same flow with dry-run status. |
315
334
  | `ctx sync --rules --force` | Rewrites ContextOS-owned Ruler sections. | You changed the ContextOS install path or need to refresh `ctx-mcp`. | Removes and re-adds ContextOS-owned `mcp`, `mcp_servers.ctx-mcp`, and selected agent sections. |
316
335
  | `ctx sync --rules --no-import-codex-mcp` | Skips Codex MCP import. | You only want ContextOS' own `ctx-mcp` in Ruler. | Does not read `~/.codex/config.toml`. |
317
336
  | `ctx sync --skills` | Syncs agent skills through skillshare. | You want Codex, Claude Code, and Antigravity to share one skill source. | Installs or verifies `skillshare`, initializes it if needed, backs up and collects existing skills unless skipped, runs `skillshare sync`, and rebuilds ContextOS skill embeddings. |
318
- | `ctx sync --skills --agents <list>` | Syncs skills only for selected agents. | You want to target a subset such as `codex,claude`. | Runs `skillshare sync --agents <list>` and refreshes skill embeddings. |
337
+ | `ctx sync --skills --agents <list>` | Syncs skills only for selected agents. | You want to target a subset such as `codex,claude` or `codex,claude,agy`. | Runs `skillshare sync --agents <list>` with `agy` normalized to `antigravity`, then refreshes skill embeddings. |
319
338
  | `ctx sync --skills --dry-run` | Previews skillshare sync. | You want to inspect behavior before changing skill directories. | Runs `skillshare sync --dry-run` and skips embedding rebuild. |
320
339
  | `ctx sync --skills --no-collect` | Skips collecting existing agent skills into skillshare. | You already manage `~/.config/skillshare/skills` and only want to push it out. | Initializes/syncs skillshare without running `skillshare backup` or `skillshare collect --all`. |
321
340
  | `ctx embeddings warm -- "task"` | Prepares local semantic embedding caches. | First install, CI smoke checks, or after changing AGENTS.md/project files/skills. | Loads/downloads `Xenova/all-MiniLM-L6-v2` and writes rule, file-path, and skill vectors to `~/.ctx/contextos/embeddings.db`. |
341
+ | `ctx ruler -- <args>` | Forwards args to the installed `ruler` CLI. | You need native Ruler commands such as `init`, `apply`, or `revert`. | Preserves Ruler stdout/stderr and exit status. |
342
+ | `ctx skillshare -- <args>` | Forwards args to the installed `skillshare` CLI. | You need native skillshare commands such as `status`, `target list`, `doctor`, `push`, or `pull`. | Preserves skillshare stdout/stderr and exit status. |
322
343
  | `ctx --version` | Prints the installed ContextOS CLI version. | You want to confirm which npm version is being executed. | Prints the version from package metadata. |
323
344
 
324
345
  ## Runtime Files
package/bin/ctx.js CHANGED
@@ -24,6 +24,7 @@ import { installAntigravityMcp } from "../plugins/ctx/lib/antigravity-mcp.js";
24
24
  import { syncRules } from "../plugins/ctx/lib/ruler-sync.js";
25
25
  import { syncSkills } from "../plugins/ctx/lib/skillshare-sync.js";
26
26
  import { scanSkills, warmSkillEmbeddings } from "../plugins/ctx/lib/skill-discoverer.js";
27
+ import { parsePassthroughArgs, runPassthrough } from "../plugins/ctx/lib/passthrough.js";
27
28
 
28
29
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
29
30
  const rootDir = path.resolve(__dirname, "..");
@@ -55,10 +56,74 @@ Usage:
55
56
  ctx sync --skills --no-collect
56
57
  ctx sync --skills --agents codex,claude,antigravity
57
58
  ctx embeddings warm -- "task"
59
+ ctx ruler -- <ruler args>
60
+ ctx skillshare -- <skillshare args>
58
61
  ctx --version
59
62
  `;
60
63
  }
61
64
 
65
+ function normalizeInstallAgent(agent) {
66
+ const normalized = String(agent || "").trim().toLowerCase();
67
+ if (normalized === "antigravity") return "agy";
68
+ return normalized;
69
+ }
70
+
71
+ function createInstallProgress({ quiet = false } = {}) {
72
+ const enabled = !quiet && process.stderr.isTTY;
73
+ const frames = ["-", "\\", "|", "/"];
74
+ let percent = 0;
75
+ let label = "starting";
76
+ let frame = 0;
77
+ let timer = null;
78
+
79
+ function render() {
80
+ if (!enabled) return;
81
+ const text = `[ctx] install ${String(percent).padStart(3)}% ${frames[frame % frames.length]} ${label}`;
82
+ process.stderr.write(`\r${text.padEnd(92)}`);
83
+ frame += 1;
84
+ }
85
+
86
+ return {
87
+ start(initialLabel = "starting") {
88
+ label = initialLabel;
89
+ percent = 0;
90
+ if (enabled) {
91
+ render();
92
+ timer = setInterval(render, 120);
93
+ } else if (!quiet) {
94
+ console.log(`[ctx] install 0% ${label}`);
95
+ }
96
+ },
97
+ step(nextPercent, nextLabel) {
98
+ percent = Math.max(percent, Math.min(100, nextPercent));
99
+ label = nextLabel;
100
+ if (enabled) render();
101
+ else if (!quiet) console.log(`[ctx] install ${percent}% ${label}`);
102
+ },
103
+ done(finalLabel = "done") {
104
+ percent = 100;
105
+ label = finalLabel;
106
+ if (timer) clearInterval(timer);
107
+ timer = null;
108
+ if (enabled) {
109
+ render();
110
+ process.stderr.write("\n");
111
+ } else if (!quiet) {
112
+ console.log(`[ctx] install 100% ${label}`);
113
+ }
114
+ },
115
+ fail(errorLabel = "failed") {
116
+ label = errorLabel;
117
+ if (timer) clearInterval(timer);
118
+ timer = null;
119
+ if (enabled) {
120
+ render();
121
+ process.stderr.write("\n");
122
+ }
123
+ }
124
+ };
125
+ }
126
+
62
127
  function packageVersion() {
63
128
  try {
64
129
  const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, "package.json"), "utf8"));
@@ -85,75 +150,100 @@ function agentInstallRoot(agent) {
85
150
  }
86
151
 
87
152
  async function install({ copy = false, inject = true, agent = "codex" } = {}) {
153
+ agent = normalizeInstallAgent(agent);
88
154
  if (copy) {
89
155
  copyInstall();
90
156
  return;
91
157
  }
158
+ const progress = createInstallProgress({ quiet: false });
159
+ progress.start(`installing ${agent || "codex"}`);
92
160
 
93
- if (agent === "claude") {
94
- const installRoot = copyPackageRoot({ rootDir, targetRoot: agentInstallRoot("claude") });
95
- const hooksPath = installClaudeHooks({ installRoot, injectPromptContext: inject });
96
- const mcpConfigPath = installClaudeMcp({ installRoot });
97
- const warmResult = await warmInstallEmbeddings();
98
- console.log("Installed ctx hooks for Claude Code.");
99
- console.log(`Stable install root: ${installRoot}`);
100
- console.log(`Installed ContextOS hooks to ${hooksPath}`);
101
- console.log(`Installed ctx-mcp MCP server to ${mcpConfigPath}`);
102
- console.log(`Embedding model cache: ${modelCacheDir(contextOSDataDir())}`);
103
- console.log(`Embedding vectors cache: ${warmResult.cachePath}`);
104
- console.log(`File path embeddings warmed: ${warmResult.fileCount || 0}`);
105
- console.log(`Skill embeddings warmed: ${warmResult.skillCount || 0}`);
106
- console.log(`Prompt context injection: ${inject ? "enabled" : "quiet logging only"}`);
107
- console.log("Restart Claude Code if it was already running, then submit a task to trigger ContextOS.");
108
- return;
109
- }
161
+ try {
162
+ if (agent === "claude") {
163
+ progress.step(10, "copying package");
164
+ const installRoot = copyPackageRoot({ rootDir, targetRoot: agentInstallRoot("claude") });
165
+ progress.step(25, "installing hooks");
166
+ const hooksPath = installClaudeHooks({ installRoot, injectPromptContext: inject });
167
+ progress.step(40, "installing mcp");
168
+ const mcpConfigPath = installClaudeMcp({ installRoot });
169
+ progress.step(55, "warming embeddings");
170
+ const warmResult = await warmInstallEmbeddings();
171
+ progress.done("claude installed");
172
+ console.log("Installed ctx hooks for Claude Code.");
173
+ console.log(`Stable install root: ${installRoot}`);
174
+ console.log(`Installed ContextOS hooks to ${hooksPath}`);
175
+ console.log(`Installed ctx-mcp MCP server to ${mcpConfigPath}`);
176
+ console.log(`Embedding model cache: ${modelCacheDir(contextOSDataDir())}`);
177
+ console.log(`Embedding vectors cache: ${warmResult.cachePath}`);
178
+ console.log(`File path embeddings warmed: ${warmResult.fileCount || 0}`);
179
+ console.log(`Skill embeddings warmed: ${warmResult.skillCount || 0}`);
180
+ console.log(`Prompt context injection: ${inject ? "enabled" : "quiet logging only"}`);
181
+ console.log("Restart Claude Code if it was already running, then submit a task to trigger ContextOS.");
182
+ return;
183
+ }
184
+
185
+ if (agent === "agy") {
186
+ progress.step(10, "copying package");
187
+ const installRoot = copyPackageRoot({ rootDir, targetRoot: agentInstallRoot("agy") });
188
+ progress.step(25, "installing hooks");
189
+ const hooksPath = installAntigravityHooks({ installRoot, injectPromptContext: inject });
190
+ progress.step(40, "installing mcp");
191
+ const mcpConfigPaths = installAntigravityMcp({ installRoot });
192
+ progress.step(55, "warming embeddings");
193
+ const warmResult = await warmInstallEmbeddings();
194
+ progress.done("agy installed");
195
+ console.log("Installed ctx hooks for Antigravity.");
196
+ console.log(`Stable install root: ${installRoot}`);
197
+ console.log(`Installed ContextOS hooks to ${hooksPath}`);
198
+ console.log(`Installed ctx-mcp MCP server to ${mcpConfigPaths.join(", ")}`);
199
+ console.log(`Embedding model cache: ${modelCacheDir(contextOSDataDir())}`);
200
+ console.log(`Embedding vectors cache: ${warmResult.cachePath}`);
201
+ console.log(`File path embeddings warmed: ${warmResult.fileCount || 0}`);
202
+ console.log(`Skill embeddings warmed: ${warmResult.skillCount || 0}`);
203
+ console.log(`Prompt context injection: ${inject ? "enabled" : "quiet logging only"}`);
204
+ console.log("Restart Antigravity or agy if it was already running, then submit a task to trigger ContextOS.");
205
+ return;
206
+ }
207
+
208
+ if (agent !== "codex") {
209
+ throw new Error(`Unknown agent '${agent}'. Expected codex, claude, or agy.`);
210
+ }
211
+
212
+ progress.step(10, "copying marketplace");
213
+ const marketplaceRoot = path.join(codexHome(), "marketplaces", "contextos");
214
+ copyPackageRoot({ rootDir, targetRoot: marketplaceRoot });
215
+
216
+ progress.step(20, "refreshing codex plugin");
217
+ tryRunCodex(["plugin", "remove", "ctx@contextos"]);
218
+ tryRunCodex(["plugin", "marketplace", "remove", "contextos"]);
219
+ tryRunCodex(["mcp", "remove", "ctx-mcp"]);
220
+ runCodex(["plugin", "marketplace", "add", marketplaceRoot]);
221
+ runCodex(["plugin", "add", "ctx@contextos"]);
222
+ progress.step(40, "installing mcp");
223
+ runCodex(["mcp", "add", "ctx-mcp", "--", "node", path.join(marketplaceRoot, "plugins", "ctx", "mcp", "server.js")]);
224
+ progress.step(50, "installing telemetry proxies");
225
+ const proxyResult = installMcpTelemetryProxies({ codexHome: codexHome(), marketplaceRoot });
226
+ progress.step(60, "installing hooks");
227
+ const hooksPath = installGlobalHooks({ codexHome: codexHome(), marketplaceRoot, injectPromptContext: inject });
110
228
 
111
- if (agent === "agy") {
112
- const installRoot = copyPackageRoot({ rootDir, targetRoot: agentInstallRoot("agy") });
113
- const hooksPath = installAntigravityHooks({ installRoot, injectPromptContext: inject });
114
- const mcpConfigPaths = installAntigravityMcp({ installRoot });
229
+ progress.step(70, "warming embeddings");
115
230
  const warmResult = await warmInstallEmbeddings();
116
- console.log("Installed ctx hooks for Antigravity.");
117
- console.log(`Stable install root: ${installRoot}`);
118
- console.log(`Installed ContextOS hooks to ${hooksPath}`);
119
- console.log(`Installed ctx-mcp MCP server to ${mcpConfigPaths.join(", ")}`);
231
+ progress.done("codex installed");
232
+ console.log("Installed ctx through Codex plugin marketplace.");
233
+ console.log(`Stable marketplace root: ${marketplaceRoot}`);
234
+ console.log(`Installed ContextOS global hooks to ${hooksPath}`);
235
+ console.log("Installed ctx-mcp MCP server.");
236
+ console.log(`MCP telemetry proxies: ${proxyResult.wrapped.length ? proxyResult.wrapped.map((item) => item.name).join(", ") : "none changed"}`);
120
237
  console.log(`Embedding model cache: ${modelCacheDir(contextOSDataDir())}`);
121
238
  console.log(`Embedding vectors cache: ${warmResult.cachePath}`);
122
239
  console.log(`File path embeddings warmed: ${warmResult.fileCount || 0}`);
123
240
  console.log(`Skill embeddings warmed: ${warmResult.skillCount || 0}`);
124
241
  console.log(`Prompt context injection: ${inject ? "enabled" : "quiet logging only"}`);
125
- console.log("Restart Antigravity or agy if it was already running, then submit a task to trigger ContextOS.");
126
- return;
127
- }
128
-
129
- if (agent !== "codex") {
130
- throw new Error(`Unknown agent '${agent}'. Expected codex, claude, or agy.`);
242
+ console.log("Restart Codex if it was already running, then submit a task to trigger ContextOS.");
243
+ } catch (error) {
244
+ progress.fail("install failed");
245
+ throw error;
131
246
  }
132
-
133
- const marketplaceRoot = path.join(codexHome(), "marketplaces", "contextos");
134
- copyPackageRoot({ rootDir, targetRoot: marketplaceRoot });
135
-
136
- tryRunCodex(["plugin", "remove", "ctx@contextos"]);
137
- tryRunCodex(["plugin", "marketplace", "remove", "contextos"]);
138
- tryRunCodex(["mcp", "remove", "ctx-mcp"]);
139
- runCodex(["plugin", "marketplace", "add", marketplaceRoot]);
140
- runCodex(["plugin", "add", "ctx@contextos"]);
141
- runCodex(["mcp", "add", "ctx-mcp", "--", "node", path.join(marketplaceRoot, "plugins", "ctx", "mcp", "server.js")]);
142
- const proxyResult = installMcpTelemetryProxies({ codexHome: codexHome(), marketplaceRoot });
143
- const hooksPath = installGlobalHooks({ codexHome: codexHome(), marketplaceRoot, injectPromptContext: inject });
144
-
145
- const warmResult = await warmInstallEmbeddings();
146
- console.log("Installed ctx through Codex plugin marketplace.");
147
- console.log(`Stable marketplace root: ${marketplaceRoot}`);
148
- console.log(`Installed ContextOS global hooks to ${hooksPath}`);
149
- console.log("Installed ctx-mcp MCP server.");
150
- console.log(`MCP telemetry proxies: ${proxyResult.wrapped.length ? proxyResult.wrapped.map((item) => item.name).join(", ") : "none changed"}`);
151
- console.log(`Embedding model cache: ${modelCacheDir(contextOSDataDir())}`);
152
- console.log(`Embedding vectors cache: ${warmResult.cachePath}`);
153
- console.log(`File path embeddings warmed: ${warmResult.fileCount || 0}`);
154
- console.log(`Skill embeddings warmed: ${warmResult.skillCount || 0}`);
155
- console.log(`Prompt context injection: ${inject ? "enabled" : "quiet logging only"}`);
156
- console.log("Restart Codex if it was already running, then submit a task to trigger ContextOS.");
157
247
  }
158
248
 
159
249
  async function warmInstallEmbeddings() {
@@ -309,9 +399,9 @@ const command = args[0];
309
399
 
310
400
  function installAgentFromArgs(args) {
311
401
  const agentFlag = args.indexOf("--agent");
312
- if (agentFlag >= 0) return args[agentFlag + 1] || "";
402
+ if (agentFlag >= 0) return normalizeInstallAgent(args[agentFlag + 1] || "");
313
403
  const firstValue = args.slice(1).find((arg) => !arg.startsWith("--"));
314
- return firstValue || "codex";
404
+ return normalizeInstallAgent(firstValue || "codex");
315
405
  }
316
406
 
317
407
  try {
@@ -322,7 +412,7 @@ try {
322
412
  } else if (command === "install") {
323
413
  await install({
324
414
  copy: args.includes("--copy"),
325
- inject: !args.includes("--quiet"),
415
+ inject: args.includes("--inject") || !args.includes("--quiet"),
326
416
  agent: installAgentFromArgs(args)
327
417
  });
328
418
  } else if (command === "debug") {
@@ -364,6 +454,15 @@ try {
364
454
  } else {
365
455
  await syncRules({ cwd: process.cwd(), rootDir, args: args.slice(1) });
366
456
  }
457
+ } else if (command === "ruler" || command === "skillshare") {
458
+ const passthrough = parsePassthroughArgs(args);
459
+ const result = runPassthrough(passthrough);
460
+ if (result.signal) {
461
+ console.error(`${passthrough.command} terminated by signal ${result.signal}`);
462
+ process.exitCode = 1;
463
+ } else {
464
+ process.exitCode = result.status;
465
+ }
367
466
  } else {
368
467
  throw new Error(`Unknown command: ${command}\n\n${usage()}`);
369
468
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minhpnq1807/contextos",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Task-aware AGENTS.md context injection and compliance reporting for Codex, Claude Code, and Antigravity.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,50 @@
1
+ import { spawnSync } from "node:child_process";
2
+
3
+ const SUPPORTED_COMMANDS = new Set(["ruler", "skillshare"]);
4
+
5
+ export function parsePassthroughArgs(args = []) {
6
+ const command = args[0];
7
+ if (!SUPPORTED_COMMANDS.has(command)) {
8
+ throw new Error(`Unsupported passthrough command: ${command || ""}`);
9
+ }
10
+
11
+ const separator = args.indexOf("--");
12
+ if (separator < 0) {
13
+ throw new Error(`Usage: ctx ${command} -- <${command} args>`);
14
+ }
15
+
16
+ return {
17
+ command,
18
+ args: args.slice(separator + 1)
19
+ };
20
+ }
21
+
22
+ export function runPassthrough({
23
+ command,
24
+ args = [],
25
+ spawn = spawnSync,
26
+ cwd = process.cwd(),
27
+ env = process.env
28
+ } = {}) {
29
+ if (!SUPPORTED_COMMANDS.has(command)) {
30
+ throw new Error(`Unsupported passthrough command: ${command || ""}`);
31
+ }
32
+
33
+ const result = spawn(command, args, {
34
+ cwd,
35
+ env,
36
+ stdio: "inherit"
37
+ });
38
+
39
+ if (result.error) {
40
+ const hint = command === "ruler"
41
+ ? "Install it with `npm install -g @intellectronica/ruler`."
42
+ : "Install it with `curl -fsSL https://raw.githubusercontent.com/runkids/skillshare/main/install.sh | sh`.";
43
+ throw new Error(`Failed to run ${command}: ${result.error.message}. ${hint}`);
44
+ }
45
+
46
+ return {
47
+ status: typeof result.status === "number" ? result.status : 1,
48
+ signal: result.signal || null
49
+ };
50
+ }
@@ -7,6 +7,12 @@ import { execFileSync } from "node:child_process";
7
7
  const DEFAULT_AGENTS = ["codex", "claude", "antigravity"];
8
8
  const CTX_MCP_NAME = "ctx-mcp";
9
9
  const CONTEXTOS_PROXY_MARKER = "/contextos/plugins/ctx/mcp/proxy.js";
10
+ const AGENT_ALIASES = new Map([
11
+ ["agy", "antigravity"],
12
+ ["antigravity", "antigravity"],
13
+ ["codex", "codex"],
14
+ ["claude", "claude"]
15
+ ]);
10
16
 
11
17
  function statusLine(label, value) {
12
18
  return `[ctx] ${label.padEnd(38)} ${value}`;
@@ -21,7 +27,7 @@ function runCommand(command, args, { cwd = process.cwd(), stdio = "pipe", dryRun
21
27
  export function parseSyncRulesArgs(args = []) {
22
28
  const agentsFlag = args.indexOf("--agents");
23
29
  const agents = agentsFlag >= 0
24
- ? String(args[agentsFlag + 1] || "").split(",").map((item) => item.trim()).filter(Boolean)
30
+ ? normalizeAgentList(String(args[agentsFlag + 1] || "").split(","))
25
31
  : DEFAULT_AGENTS;
26
32
  return {
27
33
  rules: args.includes("--rules"),
@@ -33,6 +39,19 @@ export function parseSyncRulesArgs(args = []) {
33
39
  };
34
40
  }
35
41
 
42
+ export function normalizeAgentName(agent) {
43
+ const key = String(agent || "").trim().toLowerCase();
44
+ return AGENT_ALIASES.get(key) || key;
45
+ }
46
+
47
+ export function normalizeAgentList(agents = []) {
48
+ return [...new Set(agents.map(normalizeAgentName).filter(Boolean))];
49
+ }
50
+
51
+ function displayAgentName(agent) {
52
+ return agent === "antigravity" ? "agy" : agent;
53
+ }
54
+
36
55
  function codexConfigPath() {
37
56
  return path.join(process.env.CODEX_HOME || path.join(process.env.HOME || process.cwd(), ".codex"), "config.toml");
38
57
  }
@@ -378,7 +397,7 @@ export function injectCtxMcp({ tomlPath, mcpServerPath, agents = DEFAULT_AGENTS,
378
397
  }
379
398
 
380
399
  export function runRulerApply({ agents = DEFAULT_AGENTS, cwd = process.cwd(), run = runCommand, dryRun = false } = {}) {
381
- run("ruler", ["apply", "--agents", agents.join(",")], { cwd, stdio: "inherit", dryRun });
400
+ run("ruler", ["apply", "--agents", normalizeAgentList(agents).join(",")], { cwd, stdio: "inherit", dryRun });
382
401
  }
383
402
 
384
403
  function fileContains(filePath, pattern) {
@@ -481,7 +500,7 @@ export async function syncRules({
481
500
  logger("[ctx] Verifying sync...");
482
501
  const checks = options.dryRun ? options.agents.map((agent) => ({ agent, ok: true, filePath: "(dry-run)" })) : verifySync({ cwd, agents: options.agents });
483
502
  for (const check of checks) {
484
- logger(` → ctx-mcp in ${check.agent.padEnd(12)} ${check.ok ? "✓" : "not found"}${check.filePath ? ` ${check.filePath}` : ""}`);
503
+ logger(` → ctx-mcp in ${displayAgentName(check.agent).padEnd(12)} ${check.ok ? "✓" : "not found"}${check.filePath ? ` ${check.filePath}` : ""}`);
485
504
  }
486
505
 
487
506
  const okCount = checks.filter((check) => check.ok).length;
@@ -8,6 +8,12 @@ import { execFileSync, execSync } from "node:child_process";
8
8
  const DEFAULT_AGENTS = ["codex", "claude", "antigravity"];
9
9
  const INSTALL_SH_URL = "https://raw.githubusercontent.com/runkids/skillshare/main/install.sh";
10
10
  const INSTALL_PS_URL = "https://raw.githubusercontent.com/runkids/skillshare/main/install.ps1";
11
+ const AGENT_ALIASES = new Map([
12
+ ["agy", "antigravity"],
13
+ ["antigravity", "antigravity"],
14
+ ["codex", "codex"],
15
+ ["claude", "claude"]
16
+ ]);
11
17
 
12
18
  function statusLine(label, value) {
13
19
  return `[ctx] ${label.padEnd(38)} ${value}`;
@@ -28,7 +34,7 @@ function runShell(command, { cwd = process.cwd(), stdio = "inherit", dryRun = fa
28
34
  export function parseSyncSkillsArgs(args = []) {
29
35
  const agentsFlag = args.indexOf("--agents");
30
36
  const agents = agentsFlag >= 0
31
- ? String(args[agentsFlag + 1] || "").split(",").map((item) => item.trim()).filter(Boolean)
37
+ ? normalizeAgentList(String(args[agentsFlag + 1] || "").split(","))
32
38
  : DEFAULT_AGENTS;
33
39
  return {
34
40
  skills: args.includes("--skills"),
@@ -39,6 +45,15 @@ export function parseSyncSkillsArgs(args = []) {
39
45
  };
40
46
  }
41
47
 
48
+ function normalizeAgentName(agent) {
49
+ const key = String(agent || "").trim().toLowerCase();
50
+ return AGENT_ALIASES.get(key) || key;
51
+ }
52
+
53
+ function normalizeAgentList(agents = []) {
54
+ return [...new Set(agents.map(normalizeAgentName).filter(Boolean))];
55
+ }
56
+
42
57
  export function detectOS(platform = process.platform) {
43
58
  if (platform === "darwin") return "mac";
44
59
  if (platform === "win32") return "windows";