@minhpnq1807/contextos 0.5.53 → 0.6.0

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: ContextOS Community
3
+ description: Maintain Community Skill Packs, certification docs, launch demos, and distribution-oriented ContextOS assets.
4
+ ---
5
+
6
+ # ContextOS Community
7
+
8
+ Use this skill for Community Skill Packs, ContextOS Ready certification, launch demos, roadmap docs, and contributor-facing assets.
9
+
10
+ ## Workflow
11
+
12
+ 1. Keep community assets small and PR-friendly.
13
+ 2. Prefer docs, examples, and tests over hosted infrastructure.
14
+ 3. Ensure every skill pack has triggers, evidence, negative triggers, and workflow.
15
+ 4. Validate docs and package inclusion before committing.
@@ -0,0 +1,20 @@
1
+ id: contextos-community
2
+ name: ContextOS Community
3
+ description: Maintain Community Skill Packs, certification docs, launch demos, and distribution assets.
4
+ positive_triggers:
5
+ prompts: [community skill packs, contextos ready, certified, badge, roadmap, launch demo, contributor]
6
+ files: [community-skills/README.md, docs/roadmap.md, docs/launch-demos.md, README.md]
7
+ dependencies: [vitest]
8
+ evidence:
9
+ files: [community-skills/README.md, docs/roadmap.md, README.md]
10
+ dependencies: [vitest]
11
+ negative_triggers:
12
+ prompts: [runtime scorer, mcp transport, embedding model]
13
+ workflow:
14
+ - Keep community assets small and PR-friendly.
15
+ - Prefer docs, examples, and tests over hosted infrastructure.
16
+ - Ensure every skill pack has triggers, evidence, negative triggers, and workflow.
17
+ - Validate docs and package inclusion before committing.
18
+ related_skills:
19
+ - community-management
20
+ - technical-writing
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: ContextOS Release
3
+ description: Prepare ContextOS npm package releases, changelog updates, plugin validation, tags, and GitHub release safety checks.
4
+ ---
5
+
6
+ # ContextOS Release
7
+
8
+ Use this skill when bumping versions, preparing changelog entries, validating package contents, or publishing ContextOS.
9
+
10
+ ## Workflow
11
+
12
+ 1. Update README and CHANGELOG before tagging.
13
+ 2. Verify package and plugin versions stay aligned.
14
+ 3. Run build, plugin validation, MCP smoke, tests, and `npm pack --dry-run`.
15
+ 4. Commit, tag, push, and verify the GitHub release/npm publish path.
@@ -0,0 +1,20 @@
1
+ id: contextos-release
2
+ name: ContextOS Release
3
+ description: Prepare ContextOS npm releases, changelog updates, tags, and package validation.
4
+ positive_triggers:
5
+ prompts: [release, bump version, changelog, npm publish, tag, package, validate plugin]
6
+ files: [package.json, plugins/ctx/.codex-plugin/plugin.json, CHANGELOG.md, README.md]
7
+ dependencies: [vitest]
8
+ evidence:
9
+ files: [package.json, plugins/ctx/.codex-plugin/plugin.json, CHANGELOG.md]
10
+ dependencies: [vitest]
11
+ negative_triggers:
12
+ prompts: [application feature, dashboard UI, backend API]
13
+ workflow:
14
+ - Update README and CHANGELOG before tagging.
15
+ - Verify package and plugin versions stay aligned.
16
+ - Run build, plugin validation, MCP smoke, tests, and npm pack dry-run.
17
+ - Commit, tag, push, and verify release automation.
18
+ related_skills:
19
+ - npm-package-release
20
+ - github-actions-ci-cd
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: ContextOS Routing
3
+ description: Work on ContextOS rule, file, skill, workflow, and evidence routing without adding broad runtime complexity.
4
+ ---
5
+
6
+ # ContextOS Routing
7
+
8
+ Use this skill when changing ContextOS routing behavior, prompt hook output, scoring, evidence, or MCP scorer paths.
9
+
10
+ ## Workflow
11
+
12
+ 1. Inspect the existing routing module before changing behavior.
13
+ 2. Keep prompt-hook hot paths bounded and fail-open.
14
+ 3. Add focused tests for ranking, output, or telemetry behavior.
15
+ 4. Run `npm test`, `npm run build`, and `npm run validate:plugin` when the change affects runtime.
@@ -0,0 +1,20 @@
1
+ id: contextos-routing
2
+ name: ContextOS Routing
3
+ description: Work on ContextOS rule, file, skill, workflow, and evidence routing.
4
+ positive_triggers:
5
+ prompts: [contextos routing, prompt hook, skill router, workflow router, evidence, scoring, ctx-mcp]
6
+ files: [plugins/ctx/lib/score-context.js, plugins/ctx/lib/skill-discoverer.js, plugins/ctx/lib/workflow-discoverer.js, plugins/ctx/lib/prompt-hook.js]
7
+ dependencies: [@modelcontextprotocol/sdk]
8
+ evidence:
9
+ files: [plugins/ctx/lib/score-context.js, plugins/ctx/lib/skill-discoverer.js, plugins/ctx/mcp/server.js]
10
+ dependencies: [@modelcontextprotocol/sdk, @xenova/transformers]
11
+ negative_triggers:
12
+ prompts: [dashboard, cloud service, hosted marketplace]
13
+ workflow:
14
+ - Inspect the existing routing module before changing behavior.
15
+ - Keep prompt-hook hot paths bounded and fail-open.
16
+ - Add focused tests for ranking, output, or telemetry behavior.
17
+ - Run npm test plus build and plugin validation for runtime changes.
18
+ related_skills:
19
+ - mcp-tool-developer
20
+ - agent-memory-mcp
@@ -0,0 +1,13 @@
1
+ # Primary ContextOS Workflow
2
+
3
+ Use this workflow for feature implementation, debugging, routing changes, and test fixes in ContextOS.
4
+
5
+ planner -> researcher -> tester -> code-reviewer -> docs-manager
6
+
7
+ ## Steps
8
+
9
+ 1. Confirm the affected ContextOS surface: CLI, prompt hook, MCP server, router, setup, docs, or tests.
10
+ 2. Inspect the existing module and nearby tests before patching.
11
+ 3. Keep runtime behavior local-first, bounded, and fail-open.
12
+ 4. Add focused tests for the changed behavior.
13
+ 5. Run the relevant validation commands before commit.
@@ -0,0 +1,12 @@
1
+ # ContextOS Release Workflow
2
+
3
+ Use this workflow for version bumps, changelog updates, package validation, tags, and release checks.
4
+
5
+ planner -> tester -> docs-manager -> code-reviewer
6
+
7
+ ## Steps
8
+
9
+ 1. Update package and plugin versions together when releasing.
10
+ 2. Update README and CHANGELOG with user-visible behavior.
11
+ 3. Run tests, build, plugin validation, MCP smoke, and package dry-run.
12
+ 4. Commit, tag, push, and verify the release automation result.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0
4
+
5
+ - **Launch demo framing:** Added Agent Hallucination Benchmark messaging, same-prompt/same-model/different-context copy, and `docs/launch-demos.md` with three short demo scripts: hallucination benchmark, AGENTS.md lost-in-the-middle, and repo-aware skills.
6
+ - **Roadmap template expansion:** Extended the launch roadmap issue template with Hallucination Benchmark, Agent Replay, and Community Skill Packs areas.
7
+ - **Roadmap docs:** Added `docs/roadmap.md` covering Hallucination Leaderboard, Agent Replay, Community Skill Packs, and ContextOS Ready certification without committing to dashboard/cloud work.
8
+ - **Community Skill Packs:** Added the initial `community-skills/` seed packs for EAS, Vercel, Prisma, Redis, Google OAuth, and JWT auth with `SKILL.md`, `skill.yaml`, contribution docs, and routing contract tests.
9
+ - **ContextOS Ready:** Added `ctx doctor` to score repository readiness across project rules, skill packs, and workflows, plus README badge/docs and certification tests.
10
+ - **Auto Skill Extraction roadmap:** Documented `ctx skill generate` as a research direction for detecting reusable repository skills and drafting publishable skill packs from project evidence.
11
+
3
12
  ## 0.5.53
4
13
 
5
14
  - **Optional adapter positioning:** Clarified that ContextOS core works standalone and that `code-review-graph`, `codegraph`, and `agent-memory` are optional adapters. Skill Router scoring now exposes separate `importGraphScore`, `externalGraphScore`, and `memoryScore` fields so missing adapters degrade to zero score instead of becoming install/runtime requirements.
package/README.md CHANGED
@@ -6,6 +6,7 @@ Rules, files, skills, workflows, and evidence: injected before the agent writes
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/@minhpnq1807/contextos.svg)](https://www.npmjs.com/package/@minhpnq1807/contextos)
8
8
  [![CI](https://github.com/khovan123/contextOS/actions/workflows/ci.yml/badge.svg)](https://github.com/khovan123/contextOS/actions/workflows/ci.yml)
9
+ [![ContextOS Ready](https://img.shields.io/badge/ContextOS-Ready_Gold-2ea44f)](#contextos-ready)
9
10
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
11
 
11
12
  ```text
@@ -29,7 +30,7 @@ Published package: [`@minhpnq1807/contextos`](https://www.npmjs.com/package/@min
29
30
 
30
31
  ![ContextOS demo: same prompt, different repo, correct skills](docs/demo/contextos-demo.gif)
31
32
 
32
- Same prompt. Different repo. Correct skills.
33
+ Same prompt. Same model. Different context.
33
34
 
34
35
  ```bash
35
36
  ctx skills doctor -- "fix deployed"
@@ -41,6 +42,31 @@ ctx skills doctor -- "fix deployed"
41
42
  | `vercel.json`, `next`, GitHub workflow | `vercel-deployment`, `github-actions-ci-cd`, `env-secret-management` |
42
43
  | ContextOS repo with no app deploy evidence | no deployment skill selected |
43
44
 
45
+ ## Agent Hallucination Benchmark
46
+
47
+ Generic agents often guess deployment tooling from the prompt alone:
48
+
49
+ ```text
50
+ Prompt: Fix deployment
51
+ Raw agent guess: Vercel, Docker, Railway
52
+ ```
53
+
54
+ ContextOS routes from project evidence instead:
55
+
56
+ ```text
57
+ Detected evidence:
58
+ - eas.json
59
+ - expo dependency
60
+ - GitHub workflow
61
+
62
+ Selected skills:
63
+ - eas
64
+ - mobile-deployment
65
+ - github-actions-ci-cd
66
+ ```
67
+
68
+ That is the core launch demo: same prompt, same model, different repo context, correct skills.
69
+
44
70
  Skill Router internal fixture benchmark:
45
71
 
46
72
  | Metric | Result |
@@ -126,6 +152,13 @@ Developers put real operating instructions in `AGENTS.md`: use this graph tool b
126
152
 
127
153
  The problem is not that agents cannot read `AGENTS.md`. The problem is that large context windows bury the important rule in the middle, where attention is weak. ContextOS turns a static rules file into task-aware runtime context.
128
154
 
155
+ The next visible demo is not another feature. It is showing the pain in a few seconds:
156
+
157
+ ```text
158
+ Raw agent: guesses from the prompt.
159
+ ContextOS: routes from repo evidence.
160
+ ```
161
+
129
162
  ## What ContextOS Does
130
163
 
131
164
  | Layer | What happens |
@@ -160,12 +193,54 @@ ContextOS is designed to be OSS-friendly and low-friction:
160
193
 
161
194
  Positioning: ContextOS works standalone and gets smarter when graph or memory adapters are available.
162
195
 
196
+ ## Roadmap
197
+
198
+ ContextOS is not heading toward a dashboard-first product. The next work is focused on making the existing local runtime more visible and reusable:
199
+
200
+ | Next | Why |
201
+ | --- | --- |
202
+ | Hallucination Leaderboard | Compare raw agent guesses vs ContextOS evidence-routed recommendations across the same repos and tasks. |
203
+ | Agent Replay | Turn telemetry into a readable post-task narrative: prompt, selected skills, followed rules, suggested files, touched files, efficiency. |
204
+ | Community Skill Packs | Let contributors PR ContextOS-ready skills with triggers, evidence, negative gates, and workflows before building a larger hub. |
205
+ | ContextOS Ready | Define a repository readiness badge for AGENTS.md, skills, workflows, and evidence quality. |
206
+ | Auto Skill Extraction | Research `ctx skill generate` so ContextOS can detect reusable skills from a repo and propose publishable skill packs. |
207
+
208
+ See [docs/roadmap.md](docs/roadmap.md) for the current roadmap notes.
209
+
210
+ ## Community Skill Packs
211
+
212
+ ContextOS starts the community loop with [`community-skills/`](community-skills/) instead of a hosted marketplace. The seed packs are `eas`, `vercel`, `prisma`, `redis`, `oauth-google`, and `jwt-auth`.
213
+
214
+ Each pack contains a model-visible `SKILL.md` plus `skill.yaml` routing metadata with prompt triggers, project evidence, negative triggers, and a short workflow. Contributors can PR new packs by copying [`community-skills/_template/`](community-skills/_template/).
215
+
216
+ ## ContextOS Ready
217
+
218
+ `ctx doctor` scores whether a repository is ready for ContextOS-style agent routing:
219
+
220
+ ```bash
221
+ ctx doctor
222
+ ```
223
+
224
+ ```text
225
+ Repository Score
226
+
227
+ Rules: 92
228
+ Skills: 88
229
+ Workflows: 84
230
+
231
+ Overall:
232
+ ContextOS Ready Gold
233
+ ```
234
+
235
+ The score checks project `AGENTS.md` rules, project skill packs under `.codex/skills/` or `.agents/skills/`, and project workflows under `.codex/workflows/` or `.claude/workflows/`. Use the badge only after `ctx doctor` reports Bronze, Silver, or Gold.
236
+
163
237
  ## Quick Commands
164
238
 
165
239
  | Command | Use it for |
166
240
  | --- | --- |
167
241
  | `ctx setup` | Recommended first-run install flow. |
168
242
  | `ctx debug -- "Recheck authen flow"` | Preview what ContextOS would inject. |
243
+ | `ctx doctor` | Score repository readiness for the `ContextOS Ready` badge. |
169
244
  | `ctx report` | Show the last task's compliance summary. |
170
245
  | `ctx evidence` | Show why each rule was marked followed/ignored/unknown. |
171
246
  | `ctx stats` | Show workspace-level usage and effectiveness metrics. |
@@ -489,6 +564,7 @@ This warning comes from a transitive dependency in the local embedding/WASM stac
489
564
  | `ctx setup --no-skills` | Skips skillshare sync during setup. | You do not want shared skills configured. | Does not run `ctx sync --skills`. |
490
565
  | `ctx setup --quiet` | Runs setup in measurement-only mode. | You want reports/stats without visible injected prompt context. | Installs hooks with prompt context injection disabled. |
491
566
  | `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`. |
567
+ | `ctx doctor` | Scores repository ContextOS readiness. | You want to add or verify a `ContextOS Ready` badge. | Prints Rules, Skills, Workflows, Overall tier, evidence, and next recommendations. |
492
568
  | `ctx report` | Shows the last Stop-hook compliance report for the current workspace. | An agent task has finished and you want the summary again. | Prints sectioned tables for summary, rule outcomes, suggested files, and runtime telemetry from `~/.ctx/contextos/workspaces/<workspace-id>/last-report.json`. |
493
569
  | `ctx evidence` | Shows detailed evidence behind the last report for the current workspace. | You want to inspect why a rule was marked `followed`, `ignored`, `unknown`, or `unmeasurable`. | Prints a compact evidence table plus per-rule detail tables. |
494
570
  | `ctx stats` | Shows aggregate runtime metrics for the current workspace. | You want to know whether ContextOS is active and useful over time. | Prints sectioned tables for prompt/report counts, injection rate, efficiency, rule outcomes, hook events, last prompt, and last report. |
package/bin/ctx.js CHANGED
@@ -41,6 +41,7 @@ import { checkForUpdate } from "../plugins/ctx/lib/update-notifier.js";
41
41
  import { fetchSkillsForAgents, printSkillRecommendations, getAllLibraries, getInstallCommands } from "../plugins/ctx/lib/skill-library.js";
42
42
  import { invalidateCtxMcpSocket } from "../plugins/ctx/lib/ctx-mcp-client.js";
43
43
  import { runPrefixedCommand } from "../plugins/ctx/lib/shell-runner.js";
44
+ import { formatContextOSReady, inspectContextOSReady } from "../plugins/ctx/lib/certification.js";
44
45
 
45
46
  /**
46
47
  * Run a shell command with all output lines prefixed by │
@@ -190,6 +191,7 @@ Usage:
190
191
  ctx setup --no-skills Skip skill sync
191
192
  ctx setup --quiet Quiet mode (minimal output)
192
193
  ctx debug -- "task" Debug a task with ContextOS tracing
194
+ ctx doctor Score repository ContextOS readiness
193
195
  ctx report Show last ContextOS compliance report
194
196
  ctx evidence Show evidence from last report
195
197
  ctx stats Show workspace statistics
@@ -1001,6 +1003,8 @@ try {
1001
1003
  const task = marker >= 0 ? args.slice(marker + 1).join(" ") : args.slice(1).join(" ");
1002
1004
  if (!task.trim()) throw new Error('Usage: ctx debug -- "task"');
1003
1005
  await debug(task);
1006
+ } else if (command === "doctor") {
1007
+ console.log(formatContextOSReady(inspectContextOSReady({ cwd: process.cwd() })));
1004
1008
  } else if (command === "refresh") {
1005
1009
  await refresh();
1006
1010
  } else if (command === "autowarm") {
@@ -0,0 +1,42 @@
1
+ # Community Skill Packs
2
+
3
+ Community Skill Packs are the first public contribution loop for ContextOS.
4
+
5
+ This is intentionally smaller than a hosted Hub. Contributors can open a PR that adds one folder with:
6
+
7
+ ```text
8
+ community-skills/<skill-id>/
9
+ SKILL.md
10
+ skill.yaml
11
+ ```
12
+
13
+ `SKILL.md` is the model-visible operating guide. `skill.yaml` is the routing contract used by the Skill Router.
14
+
15
+ ## Contract
16
+
17
+ Every pack should define:
18
+
19
+ - `name`: Human-readable skill name.
20
+ - `positive_triggers`: Prompt, file, and dependency signals that should select the skill.
21
+ - `evidence`: Project files and dependencies that support high confidence routing.
22
+ - `negative_triggers`: Signals that should reduce confidence or reject the skill.
23
+ - `workflow`: Short execution checklist for the agent.
24
+
25
+ Use `_template/` when adding a new pack.
26
+
27
+ ## Seed Packs
28
+
29
+ - `eas`: Expo EAS build, submit, preview, and production deployment.
30
+ - `vercel`: Next.js and Vercel deployment debugging.
31
+ - `prisma`: Prisma schema, migration, generated client, and query debugging.
32
+ - `redis`: Redis cache, TTL, rate limiting, queue, and session work.
33
+ - `oauth-google`: Google OAuth login and callback flows.
34
+ - `jwt-auth`: JWT access token, refresh token, guard, and middleware work.
35
+
36
+ ## Contribution Rules
37
+
38
+ - Keep triggers specific enough to avoid false positives.
39
+ - Add negative triggers for adjacent but wrong platforms.
40
+ - Prefer project evidence over broad prompt words.
41
+ - Keep workflows compact and action-oriented.
42
+ - Do not require optional graph or memory adapters.
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: Example Skill
3
+ description: Replace this with the specific task capability this skill helps with.
4
+ ---
5
+
6
+ # Example Skill
7
+
8
+ Use this skill when the prompt and project evidence match `skill.yaml`.
9
+
10
+ ## Workflow
11
+
12
+ 1. Confirm the matching files, dependencies, or config exist.
13
+ 2. Inspect the smallest relevant implementation surface.
14
+ 3. Apply the change using the project's existing patterns.
15
+ 4. Run the narrowest useful verification command.
@@ -0,0 +1,20 @@
1
+ id: example-skill
2
+ name: Example Skill
3
+ description: Replace this with a concise skill description.
4
+ positive_triggers:
5
+ prompts: [example task, example failure]
6
+ files: [example.config.js]
7
+ dependencies: [example-package]
8
+ evidence:
9
+ files: [example.config.js]
10
+ dependencies: [example-package]
11
+ negative_triggers:
12
+ prompts: [unrelated task]
13
+ files: [wrong.config.js]
14
+ dependencies: [wrong-package]
15
+ workflow:
16
+ - Confirm project evidence before selecting this skill.
17
+ - Inspect the smallest relevant files.
18
+ - Make the targeted change.
19
+ - Run focused verification.
20
+ related_skills: []
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: Expo EAS Deployment
3
+ description: Fix Expo EAS builds, submit flows, preview builds, production releases, and mobile deployment failures.
4
+ ---
5
+
6
+ # Expo EAS Deployment
7
+
8
+ Use this skill for Expo or React Native projects with EAS evidence such as `eas.json`, `app.json`, `app.config.ts`, `expo`, or `eas-cli`.
9
+
10
+ ## Workflow
11
+
12
+ 1. Inspect `eas.json`, app config, package scripts, and CI workflow files.
13
+ 2. Identify whether the failure is credentials, profile config, native dependency, bundling, or submit configuration.
14
+ 3. Patch the smallest config or package boundary that explains the log.
15
+ 4. Verify with the relevant EAS, Expo, or package build command.
@@ -0,0 +1,23 @@
1
+ id: eas
2
+ name: Expo EAS Deployment
3
+ description: Fix Expo EAS builds, submit, Android and iOS deployment failures.
4
+ positive_triggers:
5
+ prompts: [eas, expo build, deployed, deploy, android, ios, submit, preview, production, qr, connect]
6
+ files: [eas.json, app.json, app.config.js, app.config.ts]
7
+ dependencies: [expo, eas-cli, expo-router, react-native]
8
+ evidence:
9
+ files: [eas.json, app.json, app.config.js, app.config.ts, .github/workflows/*]
10
+ dependencies: [expo, eas-cli, expo-router, react-native]
11
+ negative_triggers:
12
+ dependencies: [next, vite, vercel]
13
+ files: [vercel.json, next.config.js, next.config.ts]
14
+ workflow:
15
+ - Inspect EAS profiles, app config, package scripts, and CI workflows.
16
+ - Classify the failure as credentials, build profile, native dependency, bundling, or submit config.
17
+ - Patch only the config or package boundary that matches the log.
18
+ - Verify with the relevant Expo or EAS command.
19
+ related_skills:
20
+ - mobile-deployment
21
+ - github-actions-ci-cd
22
+ - env-secret-management
23
+ - build-log-debugging
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: JWT Auth
3
+ description: Implement and debug JWT login, access tokens, refresh tokens, guards, middleware, and authorization headers.
4
+ ---
5
+
6
+ # JWT Auth
7
+
8
+ Use this skill when the prompt mentions JWT, access tokens, refresh tokens, bearer auth, guards, or token verification with project evidence such as `jsonwebtoken` or auth middleware.
9
+
10
+ ## Workflow
11
+
12
+ 1. Inspect token signing, verification, expiry, refresh rotation, and guard or middleware wiring.
13
+ 2. Confirm how tokens are stored and sent by clients.
14
+ 3. Patch the narrow auth boundary without changing unrelated authorization policy.
15
+ 4. Verify with focused auth tests and typecheck.
@@ -0,0 +1,22 @@
1
+ id: jwt-auth
2
+ name: JWT Auth
3
+ description: Implement and debug JWT authentication, refresh tokens, access tokens, guards, middleware, and login authorization.
4
+ positive_triggers:
5
+ prompts: [jwt, auth, token, access token, refresh token, bearer, login, guard, middleware]
6
+ files: [auth.guard.ts, jwt.strategy.ts, middleware.ts]
7
+ dependencies: [jsonwebtoken, jose, @nestjs/jwt, passport-jwt]
8
+ evidence:
9
+ files: [auth.guard.ts, jwt.strategy.ts, middleware.ts, .env.example]
10
+ dependencies: [jsonwebtoken, jose, @nestjs/jwt, passport-jwt]
11
+ negative_triggers:
12
+ prompts: [google oauth, social login, saml]
13
+ dependencies: [next-auth, @auth/core, passport-google-oauth20]
14
+ workflow:
15
+ - Inspect signing, verification, expiry, refresh rotation, and guard or middleware wiring.
16
+ - Confirm token storage and client authorization headers.
17
+ - Patch the narrow auth boundary without changing unrelated authorization policy.
18
+ - Verify with focused auth tests and typecheck.
19
+ related_skills:
20
+ - oauth-google
21
+ - backend-security-coder
22
+ - api-security-best-practices
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: Google OAuth
3
+ description: Implement and debug Google OAuth login, callback routes, Auth.js or NextAuth providers, scopes, and account linking.
4
+ ---
5
+
6
+ # Google OAuth
7
+
8
+ Use this skill when the prompt mentions Google sign-in or OAuth and the repo has OAuth evidence such as `next-auth`, `@auth/core`, Passport Google OAuth, or auth callback routes.
9
+
10
+ ## Workflow
11
+
12
+ 1. Inspect provider configuration, callback URL handling, scopes, secrets, and session creation.
13
+ 2. Verify that frontend login entrypoints and backend callback routes agree.
14
+ 3. Patch the smallest auth boundary and keep existing session/token conventions.
15
+ 4. Verify with focused auth tests, typecheck, or a local OAuth callback path when available.
@@ -0,0 +1,22 @@
1
+ id: oauth-google
2
+ name: Google OAuth
3
+ description: Implement and debug Google OAuth login, OAuth callback routes, Auth.js, NextAuth, Passport providers, and social sign-in.
4
+ positive_triggers:
5
+ prompts: [oauth, google login, google sign in, callback, social login, auth provider]
6
+ files: [auth.config.ts, auth.ts, pages/api/auth/*, app/api/auth/*]
7
+ dependencies: [next-auth, @auth/core, passport-google-oauth20]
8
+ evidence:
9
+ files: [auth.config.ts, auth.ts, pages/api/auth/*, app/api/auth/*, .env.example]
10
+ dependencies: [next-auth, @auth/core, passport, passport-google-oauth20]
11
+ negative_triggers:
12
+ prompts: [jwt only, password login, refresh token only]
13
+ dependencies: [jsonwebtoken]
14
+ workflow:
15
+ - Inspect provider config, callback URLs, scopes, secrets, and session creation.
16
+ - Verify frontend login entrypoints and backend callback routes agree.
17
+ - Patch the smallest auth boundary while preserving session conventions.
18
+ - Verify with focused auth tests, typecheck, or local callback flow.
19
+ related_skills:
20
+ - jwt-auth
21
+ - env-secret-management
22
+ - auth-implementation-patterns
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: Prisma
3
+ description: Debug Prisma schemas, migrations, generated client issues, relations, transactions, and slow ORM queries.
4
+ ---
5
+
6
+ # Prisma
7
+
8
+ Use this skill when the repo contains Prisma evidence such as `prisma/schema.prisma`, `@prisma/client`, or `prisma`.
9
+
10
+ ## Workflow
11
+
12
+ 1. Inspect `prisma/schema.prisma`, generated client usage, migrations, and package scripts.
13
+ 2. Determine whether the issue is schema shape, migration state, generated types, query logic, or transaction behavior.
14
+ 3. Patch the schema or service layer in the smallest compatible step.
15
+ 4. Verify with Prisma generate/migrate checks and the relevant test or typecheck.
@@ -0,0 +1,22 @@
1
+ id: prisma
2
+ name: Prisma
3
+ description: Debug Prisma schema, migrations, generated client, relations, and ORM queries.
4
+ positive_triggers:
5
+ prompts: [prisma, migration, schema, database, query, relation, transaction, generated client]
6
+ files: [prisma/schema.prisma]
7
+ dependencies: [prisma, @prisma/client]
8
+ evidence:
9
+ files: [prisma/schema.prisma, prisma/migrations/*]
10
+ dependencies: [prisma, @prisma/client]
11
+ negative_triggers:
12
+ dependencies: [mongoose, mongodb, sequelize, typeorm]
13
+ files: [drizzle.config.ts]
14
+ workflow:
15
+ - Inspect schema, migrations, generated client usage, and package scripts.
16
+ - Classify the issue as schema, migration, generated type, query, or transaction behavior.
17
+ - Patch the smallest schema or service boundary.
18
+ - Verify with Prisma generate or migrate checks plus focused tests.
19
+ related_skills:
20
+ - database
21
+ - nestjs-module
22
+ - integration-testing
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: Redis
3
+ description: Add and debug Redis caching, TTLs, sessions, queues, rate limits, and cache invalidation.
4
+ ---
5
+
6
+ # Redis
7
+
8
+ Use this skill when the repo has Redis evidence such as `redis`, `ioredis`, BullMQ, session stores, or cache modules.
9
+
10
+ ## Workflow
11
+
12
+ 1. Inspect Redis client setup, cache keys, TTL policy, and invalidation paths.
13
+ 2. Confirm whether Redis is used for cache, queue, session, rate limit, or pub/sub behavior.
14
+ 3. Patch the smallest client/service boundary and preserve existing key conventions.
15
+ 4. Verify with focused tests or a local command that exercises the Redis path.
@@ -0,0 +1,22 @@
1
+ id: redis
2
+ name: Redis
3
+ description: Add and debug Redis cache, TTL, sessions, rate limits, queues, and pub/sub behavior.
4
+ positive_triggers:
5
+ prompts: [redis, cache, caching, ttl, session, rate limit, queue, bullmq, invalidation]
6
+ files: [redis.conf, docker-compose.yml]
7
+ dependencies: [redis, ioredis, bullmq, cache-manager-redis-store]
8
+ evidence:
9
+ files: [redis.conf, docker-compose.yml, docker-compose.yaml]
10
+ dependencies: [redis, ioredis, bullmq, cache-manager, cache-manager-redis-store]
11
+ negative_triggers:
12
+ prompts: [browser cache, next cache, static cache]
13
+ dependencies: [swr]
14
+ workflow:
15
+ - Inspect client setup, cache keys, TTLs, and invalidation paths.
16
+ - Identify whether Redis backs cache, queue, session, rate limit, or pub/sub behavior.
17
+ - Patch the smallest service boundary while preserving key conventions.
18
+ - Verify with focused tests or a command that exercises the Redis path.
19
+ related_skills:
20
+ - performance-optimization
21
+ - backend-development
22
+ - observability
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: Vercel Deployment
3
+ description: Fix Next.js and Vercel deployment failures, environment issues, build output problems, and production routing regressions.
4
+ ---
5
+
6
+ # Vercel Deployment
7
+
8
+ Use this skill when the repo has Vercel or Next.js evidence such as `vercel.json`, `next`, or `next.config.*`.
9
+
10
+ ## Workflow
11
+
12
+ 1. Inspect `vercel.json`, Next config, package scripts, and deployment logs.
13
+ 2. Check build command, output directory, environment variables, and route/runtime settings.
14
+ 3. Patch the minimal config or code path that explains the deployment failure.
15
+ 4. Verify with the project build command and any available Vercel validation.
@@ -0,0 +1,22 @@
1
+ id: vercel
2
+ name: Vercel Deployment
3
+ description: Fix Vercel and Next.js deployment failures.
4
+ positive_triggers:
5
+ prompts: [vercel, deployed, deploy, production, preview, build failed, environment variable]
6
+ files: [vercel.json, next.config.js, next.config.ts]
7
+ dependencies: [next, vercel]
8
+ evidence:
9
+ files: [vercel.json, next.config.js, next.config.ts, .github/workflows/*]
10
+ dependencies: [next, vercel, react]
11
+ negative_triggers:
12
+ dependencies: [expo, react-native, eas-cli]
13
+ files: [eas.json, app.json]
14
+ workflow:
15
+ - Inspect Vercel config, Next config, package scripts, and deploy logs.
16
+ - Check build command, output directory, env vars, runtime, and route config.
17
+ - Patch the minimal config or code path that explains the failure.
18
+ - Verify with the project build command.
19
+ related_skills:
20
+ - github-actions-ci-cd
21
+ - env-secret-management
22
+ - build-log-debugging
@@ -0,0 +1,105 @@
1
+ # Launch Demos
2
+
3
+ These are demo scripts for explaining ContextOS quickly. They are intentionally small and visual.
4
+
5
+ ## 1. Agent Hallucination Benchmark
6
+
7
+ Prompt:
8
+
9
+ ```text
10
+ Fix deployment
11
+ ```
12
+
13
+ Raw agent:
14
+
15
+ ```text
16
+ Suggests: Vercel, Docker, Railway
17
+ Reason: guessed from common deployment tools
18
+ ```
19
+
20
+ ContextOS:
21
+
22
+ ```text
23
+ Detected:
24
+ - eas.json
25
+ - expo dependency
26
+ - GitHub workflow
27
+
28
+ Selected:
29
+ - eas
30
+ - mobile-deployment
31
+ - github-actions-ci-cd
32
+ ```
33
+
34
+ Message:
35
+
36
+ ```text
37
+ Same prompt. Same model. Different context.
38
+ ```
39
+
40
+ ## 2. AGENTS.md Lost In The Middle
41
+
42
+ Setup:
43
+
44
+ ```text
45
+ AGENTS.md
46
+ rule 1
47
+ rule 2
48
+ ...
49
+ IMPORTANT: Always use code-review-graph before grep.
50
+ ...
51
+ rule 40
52
+ ```
53
+
54
+ Raw agent:
55
+
56
+ ```text
57
+ Misses the buried rule.
58
+ ```
59
+
60
+ ContextOS:
61
+
62
+ ```text
63
+ Extracts the relevant rule and injects it before work starts.
64
+ ```
65
+
66
+ Message:
67
+
68
+ ```text
69
+ Important repo rules should not depend on where they appear in a long file.
70
+ ```
71
+
72
+ ## 3. Repo-Aware Skills
73
+
74
+ Prompt:
75
+
76
+ ```text
77
+ fix deployed
78
+ ```
79
+
80
+ Repo A:
81
+
82
+ ```text
83
+ Evidence: expo, eas.json
84
+ Skills: eas, mobile-deployment
85
+ ```
86
+
87
+ Repo B:
88
+
89
+ ```text
90
+ Evidence: next, vercel.json
91
+ Skills: vercel-deployment, github-actions-ci-cd
92
+ ```
93
+
94
+ Repo C:
95
+
96
+ ```text
97
+ Evidence: Dockerfile, docker-compose.yml
98
+ Skills: docker, build-log-debugging
99
+ ```
100
+
101
+ Message:
102
+
103
+ ```text
104
+ Context is not extra text. It changes the correct answer.
105
+ ```
@@ -0,0 +1,285 @@
1
+ # Roadmap
2
+
3
+ ContextOS is past the core routing layer. The next work should make the value visible faster and create a community loop.
4
+
5
+ ## P1: Hallucination Leaderboard
6
+
7
+ The strongest launch artifact is not another feature. It is a leaderboard that shows raw prompt-only agents making plausible guesses while ContextOS routes from repo evidence.
8
+
9
+ Layout:
10
+
11
+ ```text
12
+ benchmarks/
13
+ codex/
14
+ claude-code/
15
+ cursor/
16
+ gemini-cli/
17
+ contextos/
18
+ ```
19
+
20
+ Protocol:
21
+
22
+ ```text
23
+ same repo
24
+ same task
25
+ same model when possible
26
+ same scoring rubric
27
+ ```
28
+
29
+ Example task:
30
+
31
+ ```text
32
+ Task: Fix deployment
33
+ Repo: Expo app
34
+ ```
35
+
36
+ Example result:
37
+
38
+ ```text
39
+ System Correct Skill
40
+ Raw Agent ❌
41
+ ContextOS + Codex ✅
42
+ ```
43
+
44
+ Target public table:
45
+
46
+ ```text
47
+ Hallucination Benchmark
48
+
49
+ Claude Code: 61%
50
+ Cursor: 58%
51
+ Raw Codex: 63%
52
+ ContextOS + Codex: 89%
53
+ ```
54
+
55
+ Why it matters:
56
+
57
+ - It is easy to understand in seconds.
58
+ - It turns ContextOS from infrastructure into a visible correctness story.
59
+ - It creates content for GitHub, Hacker News, Reddit, and X/Twitter.
60
+
61
+ ## P2: Agent Replay
62
+
63
+ ContextOS already records prompt context, suggested files, suggested skills, rule outcomes, telemetry, and reports. Agent Replay should turn that into a compact post-task narrative.
64
+
65
+ Planned command:
66
+
67
+ ```bash
68
+ ctx replay
69
+ ```
70
+
71
+ Target output:
72
+
73
+ ```text
74
+ Prompt:
75
+ Fix deployment
76
+
77
+ Selected skills:
78
+ - eas
79
+ - github-actions-ci-cd
80
+
81
+ Rules followed:
82
+ ✓ Use graph first
83
+
84
+ Files suggested:
85
+ ✓ eas.json
86
+ ✓ workflow.yml
87
+
88
+ Files actually touched:
89
+ ✓ eas.json
90
+ ✓ workflow.yml
91
+
92
+ Efficiency:
93
+ 94%
94
+ ```
95
+
96
+ Why it matters:
97
+
98
+ - It proves whether the injected context helped.
99
+ - It turns local telemetry into a readable artifact.
100
+ - It gives maintainers a quick way to debug agent behavior after the fact.
101
+ - It is easier to demo than raw JSON reports.
102
+
103
+ Likely inputs:
104
+
105
+ - `last-prompt-context.json`
106
+ - `last-report.json`
107
+ - `prompt-history.jsonl`
108
+ - `report-history.jsonl`
109
+ - `telemetry.jsonl`
110
+ - current git diff/status for touched files
111
+
112
+ Non-goals for the first version:
113
+
114
+ - Cloud sync
115
+ - Dashboard
116
+ - Cross-user analytics
117
+ - Long-term hosted memory
118
+
119
+ ## P3: Community Skill Packs
120
+
121
+ Do not build a full Hub first. Start with the local `community-skills/` folder that accepts PRs.
122
+
123
+ Initial packs:
124
+
125
+ ```text
126
+ community-skills/
127
+ eas/
128
+ vercel/
129
+ prisma/
130
+ redis/
131
+ oauth-google/
132
+ jwt-auth/
133
+ ```
134
+
135
+ The seed packs now live in [`community-skills/`](../community-skills/). Each pack contains:
136
+
137
+ ```text
138
+ SKILL.md
139
+ skill.yaml
140
+ ```
141
+
142
+ The Skill Router becomes more valuable when skill packs are ContextOS-ready instead of plain markdown folders.
143
+
144
+ ContextOS-ready skill packs should include:
145
+
146
+ ```yaml
147
+ id: oauth-google
148
+ name: Google OAuth
149
+ positive_triggers:
150
+ prompts: [oauth, google login, google sign in, callback]
151
+ files: [app/api/auth/*, auth.config.ts]
152
+ dependencies: [next-auth, "@auth/core"]
153
+ evidence:
154
+ files: [app/api/auth/*, auth.config.ts, .env.example]
155
+ dependencies: [next-auth, "@auth/core"]
156
+ negative_triggers:
157
+ prompts: [jwt only, password login]
158
+ dependencies: [jsonwebtoken]
159
+ workflow:
160
+ - Inspect auth provider config, callback URLs, scopes, secrets, and session creation.
161
+ - Verify frontend login entrypoints and backend callback routes agree.
162
+ - Patch the smallest auth boundary while preserving session conventions.
163
+ - Verify with focused auth tests, typecheck, or local callback flow.
164
+ ```
165
+
166
+ Possible future install flow:
167
+
168
+ ```bash
169
+ ctx skills install oauth-google
170
+ ```
171
+
172
+ or package-based:
173
+
174
+ ```bash
175
+ npm install skill-oauth-google
176
+ ctx sync --skills
177
+ ```
178
+
179
+ Why it matters:
180
+
181
+ - It creates a network effect around reusable agent capabilities.
182
+ - It gives skill authors a structured contract: triggers, evidence, negative gates, workflow.
183
+ - It lets ContextOS route capabilities by project evidence instead of popularity or keyword overlap.
184
+
185
+ Non-goals for the first version:
186
+
187
+ - Full marketplace UI
188
+ - Paid skill hosting
189
+ - Cloud account system
190
+ - Remote vector database
191
+
192
+ ## P4: ContextOS Ready
193
+
194
+ Certification can help the ecosystem self-organize without a hosted service.
195
+
196
+ ```text
197
+ ContextOS Ready
198
+ ```
199
+
200
+ Repository requirements:
201
+
202
+ ```text
203
+ AGENTS.md
204
+ skills/
205
+ workflows/
206
+ ```
207
+
208
+ Command:
209
+
210
+ ```bash
211
+ ctx doctor
212
+ ```
213
+
214
+ Target output:
215
+
216
+ ```text
217
+ Repository Score
218
+
219
+ Rules: 92
220
+ Skills: 88
221
+ Workflows: 84
222
+
223
+ Overall:
224
+ ContextOS Ready Gold
225
+ ```
226
+
227
+ Why it matters:
228
+
229
+ - It gives projects a concrete target.
230
+ - It creates a badge people can add to README files.
231
+ - It encourages community contributions without requiring a cloud product.
232
+
233
+ MVP scope:
234
+
235
+ - Local-only scoring.
236
+ - No hosted account.
237
+ - No external leaderboard dependency.
238
+ - Rules score from project `AGENTS.md`.
239
+ - Skills score from project skill packs with `SKILL.md` and `skill.yaml`.
240
+ - Workflows score from project workflow markdown with agent handoff chains.
241
+
242
+ ## P5: Auto Skill Extraction
243
+
244
+ Today, humans write `skill.yaml`. The research direction is to let ContextOS propose skill packs from repository evidence.
245
+
246
+ Possible command:
247
+
248
+ ```bash
249
+ ctx skill generate
250
+ ```
251
+
252
+ Input:
253
+
254
+ ```text
255
+ repo
256
+ ```
257
+
258
+ Output:
259
+
260
+ ```text
261
+ Detected Skill:
262
+ nestjs-module
263
+ ```
264
+
265
+ Target generated pack:
266
+
267
+ ```text
268
+ .codex/skills/nestjs-module/
269
+ SKILL.md
270
+ skill.yaml
271
+ ```
272
+
273
+ Research shape:
274
+
275
+ - Detect repeated project capabilities from dependencies, config files, route/controller names, tests, and recent git activity.
276
+ - Generate `positive_triggers`, `evidence`, `negative_triggers`, and `workflow`.
277
+ - Mark generated packs as drafts until reviewed.
278
+ - Let an agent or maintainer publish a cleaned-up pack into `community-skills/`.
279
+
280
+ Guardrails:
281
+
282
+ - Do not auto-publish generated skills.
283
+ - Do not infer high confidence from dependency names alone.
284
+ - Prefer explainable evidence over opaque model output.
285
+ - Keep generated workflows short and editable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minhpnq1807/contextos",
3
- "version": "0.5.53",
3
+ "version": "0.6.0",
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": {
@@ -10,10 +10,13 @@
10
10
  "files": [
11
11
  "bin/",
12
12
  "plugins/",
13
+ ".codex/skills/",
14
+ ".codex/workflows/",
13
15
  ".agents/",
14
16
  "README.md",
15
17
  "DEMO.md",
16
18
  "LAUNCH.md",
19
+ "community-skills/",
17
20
  "eval/",
18
21
  "docs/",
19
22
  "LICENSE",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctx",
3
- "version": "0.5.53",
3
+ "version": "0.6.0",
4
4
  "description": "Inject task-relevant AGENTS.md rules into Codex through plugin hooks.",
5
5
  "author": {
6
6
  "name": "ContextOS"
@@ -0,0 +1,223 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+
5
+ import { filterActionableRules, parseRules } from "./analyzer.js";
6
+ import { readAgentsChain } from "./reader.js";
7
+ import { scanSkills } from "./skill-discoverer.js";
8
+ import { scanWorkflows } from "./workflow-discoverer.js";
9
+
10
+ const PROJECT_SKILL_ROOTS = [
11
+ [".codex", "skills"],
12
+ [".agents", "skills"],
13
+ [".claude", "skills"],
14
+ [".gemini", "skills"],
15
+ [".gemini", "antigravity", "skills"],
16
+ [".gemini", "antigravity-cli", "skills"]
17
+ ];
18
+
19
+ const PROJECT_WORKFLOW_ROOTS = [
20
+ [".claude", "workflows"],
21
+ [".codex", "workflows"],
22
+ [".gemini", "workflows"],
23
+ [".gemini", "antigravity", "workflows"],
24
+ [".gemini", "antigravity-cli", "workflows"]
25
+ ];
26
+
27
+ export function inspectContextOSReady({ cwd = process.cwd(), home = os.homedir() } = {}) {
28
+ const root = findProjectRoot(cwd);
29
+ const rules = inspectRules({ cwd, root, home });
30
+ const skills = inspectSkills({ root });
31
+ const workflows = inspectWorkflows({ root });
32
+ const overall = Math.round((rules.score + skills.score + workflows.score) / 3);
33
+ const tier = readinessTier(overall, { rules, skills, workflows });
34
+
35
+ return {
36
+ root,
37
+ rules,
38
+ skills,
39
+ workflows,
40
+ overall,
41
+ tier,
42
+ badge: tier === "Not Ready" ? "ContextOS Ready: Not Ready" : `ContextOS Ready ${tier}`
43
+ };
44
+ }
45
+
46
+ export function formatContextOSReady(result) {
47
+ const lines = [
48
+ "Repository Score",
49
+ "",
50
+ `Rules: ${result.rules.score}`,
51
+ `Skills: ${result.skills.score}`,
52
+ `Workflows: ${result.workflows.score}`,
53
+ "",
54
+ "Overall:",
55
+ result.badge,
56
+ "",
57
+ "Evidence:",
58
+ `- Rules: ${result.rules.summary}`,
59
+ `- Skills: ${result.skills.summary}`,
60
+ `- Workflows: ${result.workflows.summary}`
61
+ ];
62
+
63
+ const next = [
64
+ ...result.rules.recommendations,
65
+ ...result.skills.recommendations,
66
+ ...result.workflows.recommendations
67
+ ];
68
+ if (next.length) {
69
+ lines.push("", "Next:");
70
+ for (const item of [...new Set(next)].slice(0, 5)) lines.push(`- ${item}`);
71
+ }
72
+
73
+ return lines.join("\n");
74
+ }
75
+
76
+ function inspectRules({ cwd, root, home }) {
77
+ const chain = readAgentsChain({ cwd, home });
78
+ const projectSources = chain.sources.filter((source) => isInsidePath(source, root));
79
+ const rules = parseRules(chain.content || "");
80
+ const actionable = filterActionableRules(rules);
81
+ const imperative = actionable.filter((rule) => /\b(always|never|must|required|use|prefer|avoid|do not|don't)\b/i.test(rule.content));
82
+ let score = 0;
83
+ const recommendations = [];
84
+
85
+ if (projectSources.length) score += 55;
86
+ else recommendations.push("Add a project AGENTS.md with repository-specific operating rules.");
87
+
88
+ if (actionable.length >= 3) score += 20;
89
+ else recommendations.push("Add at least three actionable AGENTS.md rules.");
90
+
91
+ if (imperative.length) score += 15;
92
+ else recommendations.push("Use explicit rule language such as always, never, must, use, prefer, or avoid.");
93
+
94
+ if (projectSources.length > 1 || fs.existsSync(path.join(root, ".ruler"))) score += 10;
95
+
96
+ return {
97
+ score: Math.min(100, score),
98
+ sources: projectSources,
99
+ ruleCount: rules.length,
100
+ actionableCount: actionable.length,
101
+ summary: projectSources.length
102
+ ? `${projectSources.length} AGENTS.md source(s), ${actionable.length} actionable rule(s)`
103
+ : "missing project AGENTS.md",
104
+ recommendations
105
+ };
106
+ }
107
+
108
+ function inspectSkills({ root }) {
109
+ const roots = PROJECT_SKILL_ROOTS.map((parts) => path.join(root, ...parts));
110
+ const skills = scanSkills({ cwd: root, roots, maxSkills: 500 });
111
+ const metadataFiles = findFiles(roots, (filePath) => /skill\.ya?ml$/i.test(path.basename(filePath)));
112
+ const richMetadata = metadataFiles.filter((filePath) => {
113
+ const content = safeRead(filePath);
114
+ return /^positive_triggers:/m.test(content)
115
+ && /^evidence:/m.test(content)
116
+ && /^negative_triggers:/m.test(content)
117
+ && /^workflow:/m.test(content);
118
+ });
119
+ let score = 0;
120
+ const recommendations = [];
121
+
122
+ if (skills.length) score += 50;
123
+ else recommendations.push("Add project skills under .codex/skills/ or .agents/skills/.");
124
+
125
+ if (metadataFiles.length) score += 20;
126
+ else recommendations.push("Add skill.yaml metadata beside important SKILL.md files.");
127
+
128
+ if (richMetadata.length) score += 20;
129
+ else recommendations.push("Include positive_triggers, negative_triggers, evidence, and workflow in skill.yaml.");
130
+
131
+ if (skills.length >= 3) score += 10;
132
+ else recommendations.push("Provide at least three project-relevant skills for common tasks.");
133
+
134
+ return {
135
+ score: Math.min(100, score),
136
+ count: skills.length,
137
+ metadataCount: metadataFiles.length,
138
+ richMetadataCount: richMetadata.length,
139
+ summary: skills.length
140
+ ? `${skills.length} skill(s), ${metadataFiles.length} metadata file(s)`
141
+ : "missing project skill packs",
142
+ recommendations
143
+ };
144
+ }
145
+
146
+ function inspectWorkflows({ root }) {
147
+ const roots = PROJECT_WORKFLOW_ROOTS.map((parts) => path.join(root, ...parts));
148
+ const workflows = scanWorkflows({ cwd: root, roots });
149
+ const withChain = workflows.filter((workflow) => workflow.chain?.length);
150
+ let score = 0;
151
+ const recommendations = [];
152
+
153
+ if (workflows.length) score += 60;
154
+ else recommendations.push("Add project workflows under .codex/workflows/ or .claude/workflows/.");
155
+
156
+ if (withChain.length) score += 25;
157
+ else recommendations.push("Include agent handoff names such as planner, tester, code-reviewer, or docs-manager in workflow files.");
158
+
159
+ if (workflows.length >= 2) score += 15;
160
+ else recommendations.push("Provide more than one workflow when the repo has distinct delivery paths.");
161
+
162
+ return {
163
+ score: Math.min(100, score),
164
+ count: workflows.length,
165
+ chainCount: withChain.length,
166
+ summary: workflows.length
167
+ ? `${workflows.length} workflow(s), ${withChain.length} with agent chain(s)`
168
+ : "missing project workflows",
169
+ recommendations
170
+ };
171
+ }
172
+
173
+ function readinessTier(overall, { rules, skills, workflows }) {
174
+ if (rules.score < 50 || skills.score < 50 || workflows.score < 50) return "Not Ready";
175
+ if (overall >= 85) return "Gold";
176
+ if (overall >= 70) return "Silver";
177
+ if (overall >= 50) return "Bronze";
178
+ return "Not Ready";
179
+ }
180
+
181
+ function findProjectRoot(cwd) {
182
+ let current = path.resolve(cwd);
183
+ while (true) {
184
+ if (fs.existsSync(path.join(current, ".git"))) return current;
185
+ const parent = path.dirname(current);
186
+ if (parent === current) return path.resolve(cwd);
187
+ current = parent;
188
+ }
189
+ }
190
+
191
+ function findFiles(roots, predicate) {
192
+ const files = [];
193
+ for (const root of roots) walk(root, files, predicate, 0);
194
+ return files;
195
+ }
196
+
197
+ function walk(directory, files, predicate, depth) {
198
+ if (depth > 4) return;
199
+ let entries = [];
200
+ try {
201
+ entries = fs.readdirSync(directory, { withFileTypes: true });
202
+ } catch {
203
+ return;
204
+ }
205
+ for (const entry of entries) {
206
+ const filePath = path.join(directory, entry.name);
207
+ if (entry.isDirectory()) walk(filePath, files, predicate, depth + 1);
208
+ else if (entry.isFile() && predicate(filePath)) files.push(filePath);
209
+ }
210
+ }
211
+
212
+ function isInsidePath(filePath, root) {
213
+ const relative = path.relative(path.resolve(root), path.resolve(filePath));
214
+ return relative && !relative.startsWith("..") && !path.isAbsolute(relative);
215
+ }
216
+
217
+ function safeRead(filePath) {
218
+ try {
219
+ return fs.readFileSync(filePath, "utf8");
220
+ } catch {
221
+ return "";
222
+ }
223
+ }