@minhpnq1807/contextos 0.5.11 → 0.5.12

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.12
4
+
5
+ - Makes `ctx sync --workflows` synchronize unique workflow files to global Claude, Codex, and Antigravity workflow roots.
6
+ - Adds `ctx sync --workflows --agents ...` and `--dry-run`, with workflow-name dedupe to avoid duplicated workflow suggestions across agents.
7
+
3
8
  ## 0.5.11
4
9
 
5
10
  - Adds Antigravity workflow discovery roots under `.gemini/workflows`, `.gemini/antigravity/workflows`, and `.gemini/antigravity-cli/workflows`.
package/README.md CHANGED
@@ -216,10 +216,12 @@ After this, `ctx debug -- "task"` and prompt hooks can suggest skills from `~/.c
216
216
 
217
217
  ## Workflow Discovery
218
218
 
219
- ContextOS can also index Claude/Codex workflow markdown files and suggest the right workflow for the current task:
219
+ ContextOS can also sync Claude/Codex/Antigravity workflow markdown files and suggest the right workflow for the current task:
220
220
 
221
221
  ```bash
222
222
  ctx sync --workflows
223
+ ctx sync --workflows --agents codex,claude,agy
224
+ ctx sync --workflows --dry-run
223
225
  ```
224
226
 
225
227
  It scans project workflows first, then global workflows:
@@ -239,6 +241,8 @@ It scans project workflows first, then global workflows:
239
241
 
240
242
  Workflow files do not need YAML frontmatter. ContextOS reads the top `#` heading, section headings, and referenced agent names such as `planner`, `tester`, `code-reviewer`, and `docs-manager`, then warms semantic embeddings. Prompt hooks inject a `Suggested workflow for this task` section only when a workflow is relevant enough.
241
243
 
244
+ `ctx sync --workflows` reads every known project/global workflow root, keeps the first workflow for each filename/name according to root priority, then copies that unique set to the selected global agent roots. This prevents duplicate `primary-workflow` suggestions when the same workflow exists in Claude, Codex, and Antigravity directories.
245
+
242
246
  ## Modes
243
247
 
244
248
  Injection mode is the default:
@@ -384,7 +388,9 @@ This warning comes from a transitive dependency in the local embedding/WASM stac
384
388
  | `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. |
385
389
  | `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. |
386
390
  | `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`. |
387
- | `ctx sync --workflows` | Indexes agent workflow markdown files for prompt-time workflow suggestions. | You use `.claude/workflows/` or `.codex/workflows/` and want ContextOS to suggest the best workflow chain for each task. | Scans project/global workflow folders, parses headings and agent chain mentions, warms workflow embeddings, and makes `ctx debug`/prompt hooks show relevant workflow hints. |
391
+ | `ctx sync --workflows` | Syncs and indexes agent workflow markdown files for prompt-time workflow suggestions. | You use `.claude/workflows/`, `.codex/workflows/`, or Antigravity workflow folders and want every agent to see the same deduped workflow set. | Scans project/global workflow folders, dedupes by workflow name, copies unique workflows to selected global agent roots, warms workflow embeddings, and makes `ctx debug`/prompt hooks show relevant workflow hints. |
392
+ | `ctx sync --workflows --agents <list>` | Syncs workflows only for selected agents. | You want a subset such as `codex,claude` or `codex,claude,agy`. | Accepts comma-separated `codex`, `claude`, `agy`, or `antigravity`; `agy` writes the Gemini/Antigravity workflow roots. |
393
+ | `ctx sync --workflows --dry-run` | Previews workflow sync without writing files. | You want to inspect source workflows and target roots first. | Prints planned sync/index output and skips copying target files. |
388
394
  | `ctx embeddings warm -- "task"` | Prepares local semantic embedding caches. | First install, CI smoke checks, or after changing AGENTS.md/project files/skills/workflows. | Loads/downloads `Xenova/all-MiniLM-L6-v2` and writes rule, file-path, skill, and workflow vectors to `~/.ctx/contextos/embeddings.db`. |
389
395
  | `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. |
390
396
  | `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. |
package/bin/ctx.js CHANGED
@@ -63,6 +63,8 @@ Usage:
63
63
  ctx sync --rules --no-import-codex-mcp
64
64
  ctx sync --skills
65
65
  ctx sync --workflows
66
+ ctx sync --workflows --agents codex,claude,agy
67
+ ctx sync --workflows --dry-run
66
68
  ctx sync --skills --dry-run
67
69
  ctx sync --skills --no-collect
68
70
  ctx sync --skills --agents codex,claude,antigravity
@@ -571,7 +573,8 @@ try {
571
573
  await syncWorkflows({
572
574
  cwd: process.cwd(),
573
575
  dataDir: contextOSDataDir(),
574
- allowRemote: !isModelCacheReady(contextOSDataDir())
576
+ allowRemote: !isModelCacheReady(contextOSDataDir()),
577
+ args: args.slice(1)
575
578
  });
576
579
  } else if (args.includes("--skills")) {
577
580
  await syncSkills({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minhpnq1807/contextos",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
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": {
@@ -8,6 +8,7 @@ const DEFAULT_LIMIT = 2;
8
8
  const MIN_WORKFLOW_BYTES = 100;
9
9
  const MAX_DESCRIPTION_CHARS = 500;
10
10
  const DEFAULT_EMBEDDING_CANDIDATES = 40;
11
+ const DEFAULT_SYNC_AGENTS = ["claude", "codex", "agy"];
11
12
  const KNOWN_AGENT_NAMES = new Set([
12
13
  "planner",
13
14
  "tester",
@@ -42,6 +43,29 @@ export function workflowSearchRoots({ cwd = process.cwd(), home = os.homedir() }
42
43
  ];
43
44
  }
44
45
 
46
+ export function workflowGlobalRoots({ home = os.homedir(), agents = DEFAULT_SYNC_AGENTS } = {}) {
47
+ const normalizedAgents = parseWorkflowAgents(agents);
48
+ const roots = [];
49
+ if (normalizedAgents.includes("claude")) roots.push(path.join(home, ".claude", "workflows"));
50
+ if (normalizedAgents.includes("codex")) roots.push(path.join(home, ".codex", "workflows"));
51
+ if (normalizedAgents.includes("agy")) {
52
+ roots.push(path.join(home, ".gemini", "workflows"));
53
+ roots.push(path.join(home, ".gemini", "antigravity", "workflows"));
54
+ roots.push(path.join(home, ".gemini", "antigravity-cli", "workflows"));
55
+ }
56
+ return roots;
57
+ }
58
+
59
+ export function parseWorkflowAgents(value = DEFAULT_SYNC_AGENTS) {
60
+ const raw = Array.isArray(value) ? value : String(value || "").split(",");
61
+ const agents = raw
62
+ .map((agent) => String(agent || "").trim().toLowerCase())
63
+ .map((agent) => agent === "antigravity" ? "agy" : agent)
64
+ .filter(Boolean);
65
+ const known = agents.filter((agent) => DEFAULT_SYNC_AGENTS.includes(agent));
66
+ return [...new Set(known.length ? known : DEFAULT_SYNC_AGENTS)];
67
+ }
68
+
45
69
  export function scanWorkflows({ cwd = process.cwd(), roots = workflowSearchRoots({ cwd }) } = {}) {
46
70
  const workflows = [];
47
71
  const seen = new Set();
@@ -148,20 +172,67 @@ export async function syncWorkflows({
148
172
  cwd = process.cwd(),
149
173
  dataDir,
150
174
  allowRemote = true,
175
+ args = [],
176
+ home = os.homedir(),
151
177
  logger = console.log
152
178
  } = {}) {
153
- const workflows = scanWorkflows({ cwd });
154
- logger("ContextOS workflow index");
155
- logger(`Found workflows: ${workflows.length}`);
179
+ const options = parseSyncWorkflowArgs(args);
180
+ const agents = parseWorkflowAgents(options.agents);
181
+ const workflows = scanWorkflows({ cwd, roots: workflowSearchRoots({ cwd, home }) });
182
+ const targets = workflowGlobalRoots({ home, agents });
183
+
184
+ logger("ContextOS workflow sync");
185
+ logger(`Agents: ${agents.join(", ")}`);
186
+ logger(`Found unique workflows: ${workflows.length}`);
156
187
  if (workflows.length) {
157
188
  for (const workflow of workflows) {
158
189
  logger(`- ${workflow.relativePath || workflow.path} (${workflow.chain.join(" -> ") || "no chain"})`);
159
190
  }
160
191
  }
192
+ const syncResult = syncWorkflowFiles({ workflows, targets, dryRun: options.dryRun, logger });
161
193
  const result = await warmWorkflowEmbeddings({ cwd, dataDir, allowRemote, workflows });
194
+ logger(`Synced workflows: ${syncResult.copied}${options.dryRun ? " planned" : ""}`);
195
+ logger(`Skipped duplicates: ${syncResult.duplicates}`);
162
196
  logger(`Indexed workflows: ${workflows.length}`);
163
197
  if (result.cachePath) logger(`Cache: ${result.cachePath}`);
164
- return { workflows, embeddings: result };
198
+ return { workflows, embeddings: result, sync: syncResult };
199
+ }
200
+
201
+ function parseSyncWorkflowArgs(args = []) {
202
+ const agentsFlag = args.indexOf("--agents");
203
+ return {
204
+ agents: agentsFlag >= 0 ? args[agentsFlag + 1] : DEFAULT_SYNC_AGENTS,
205
+ dryRun: args.includes("--dry-run")
206
+ };
207
+ }
208
+
209
+ function syncWorkflowFiles({ workflows = [], targets = [], dryRun = false, logger = console.log } = {}) {
210
+ let copied = 0;
211
+ let duplicates = 0;
212
+ const seenNames = new Set();
213
+ for (const workflow of workflows) {
214
+ if (seenNames.has(workflow.name)) {
215
+ duplicates += 1;
216
+ continue;
217
+ }
218
+ seenNames.add(workflow.name);
219
+ for (const targetRoot of targets) {
220
+ const targetPath = path.join(targetRoot, `${workflow.name}.md`);
221
+ const sourceRealPath = safeRealpath(workflow.path) || path.resolve(workflow.path);
222
+ const targetRealPath = safeRealpath(targetPath) || path.resolve(targetPath);
223
+ if (sourceRealPath === targetRealPath) continue;
224
+ if (!dryRun) {
225
+ fs.mkdirSync(targetRoot, { recursive: true });
226
+ fs.copyFileSync(workflow.path, targetPath);
227
+ }
228
+ copied += 1;
229
+ }
230
+ }
231
+ if (targets.length) {
232
+ logger(`Target roots: ${targets.length}`);
233
+ for (const target of targets) logger(` -> ${target}`);
234
+ }
235
+ return { copied, duplicates, targets: targets.length };
165
236
  }
166
237
 
167
238
  function stripFrontmatter(content) {