opencastle 1.1.1 → 1.2.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.
- package/README.md +22 -5
- package/bin/cli.mjs +6 -0
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +24 -2
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/agent-plugin.d.ts +119 -0
- package/dist/cli/agent-plugin.d.ts.map +1 -0
- package/dist/cli/agent-plugin.js +449 -0
- package/dist/cli/agent-plugin.js.map +1 -0
- package/dist/cli/agent-plugin.test.d.ts +2 -0
- package/dist/cli/agent-plugin.test.d.ts.map +1 -0
- package/dist/cli/agent-plugin.test.js +227 -0
- package/dist/cli/agent-plugin.test.js.map +1 -0
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +99 -26
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/convoy/gates.d.ts +2 -20
- package/dist/cli/convoy/gates.d.ts.map +1 -1
- package/dist/cli/convoy/gates.js +3 -111
- package/dist/cli/convoy/gates.js.map +1 -1
- package/dist/cli/copy.d.ts +0 -8
- package/dist/cli/copy.d.ts.map +1 -1
- package/dist/cli/copy.js +0 -21
- package/dist/cli/copy.js.map +1 -1
- package/dist/cli/dispatcher.test.js +2 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +2 -0
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +2 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/init.test.js +36 -24
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/layers.d.ts +8 -0
- package/dist/cli/layers.d.ts.map +1 -1
- package/dist/cli/layers.js +130 -13
- package/dist/cli/layers.js.map +1 -1
- package/dist/cli/layers.test.js +2 -2
- package/dist/cli/layers.test.js.map +1 -1
- package/dist/cli/legacy-install.test.js +8 -1
- package/dist/cli/legacy-install.test.js.map +1 -1
- package/dist/cli/lesson-command.test.d.ts +2 -0
- package/dist/cli/lesson-command.test.d.ts.map +1 -0
- package/dist/cli/lesson-command.test.js +100 -0
- package/dist/cli/lesson-command.test.js.map +1 -0
- package/dist/cli/lesson.d.ts +0 -9
- package/dist/cli/lesson.d.ts.map +1 -1
- package/dist/cli/lesson.js +212 -276
- package/dist/cli/lesson.js.map +1 -1
- package/dist/cli/lessons.d.ts +134 -0
- package/dist/cli/lessons.d.ts.map +1 -0
- package/dist/cli/lessons.js +493 -0
- package/dist/cli/lessons.js.map +1 -0
- package/dist/cli/lessons.test.d.ts +2 -0
- package/dist/cli/lessons.test.d.ts.map +1 -0
- package/dist/cli/lessons.test.js +214 -0
- package/dist/cli/lessons.test.js.map +1 -0
- package/dist/cli/pack-plugins.d.ts +8 -0
- package/dist/cli/pack-plugins.d.ts.map +1 -0
- package/dist/cli/pack-plugins.js +70 -0
- package/dist/cli/pack-plugins.js.map +1 -0
- package/dist/cli/plugin-command.test.d.ts +2 -0
- package/dist/cli/plugin-command.test.d.ts.map +1 -0
- package/dist/cli/plugin-command.test.js +114 -0
- package/dist/cli/plugin-command.test.js.map +1 -0
- package/dist/cli/plugin.d.ts +30 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +291 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/promote-command.test.d.ts +2 -0
- package/dist/cli/promote-command.test.d.ts.map +1 -0
- package/dist/cli/promote-command.test.js +151 -0
- package/dist/cli/promote-command.test.js.map +1 -0
- package/dist/cli/promote.d.ts +12 -0
- package/dist/cli/promote.d.ts.map +1 -0
- package/dist/cli/promote.js +364 -0
- package/dist/cli/promote.js.map +1 -0
- package/dist/cli/secret-scan.d.ts +21 -0
- package/dist/cli/secret-scan.d.ts.map +1 -0
- package/dist/cli/secret-scan.js +114 -0
- package/dist/cli/secret-scan.js.map +1 -0
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +9 -0
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/team-commands.test.js +2 -2
- package/dist/cli/team-commands.test.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +18 -0
- package/dist/cli/update.js.map +1 -1
- package/dist/orchestrator/plugins/agent-plugins.test.d.ts +2 -0
- package/dist/orchestrator/plugins/agent-plugins.test.d.ts.map +1 -0
- package/dist/orchestrator/plugins/agent-plugins.test.js +32 -0
- package/dist/orchestrator/plugins/agent-plugins.test.js.map +1 -0
- package/package.json +2 -1
- package/src/cli/adapters/single-file-base.ts +23 -2
- package/src/cli/agent-plugin.test.ts +267 -0
- package/src/cli/agent-plugin.ts +469 -0
- package/src/cli/baseline.ts +99 -26
- package/src/cli/convoy/gates.ts +9 -142
- package/src/cli/copy.ts +0 -25
- package/src/cli/dispatcher.test.ts +2 -2
- package/src/cli/docs-accuracy.test.ts +2 -0
- package/src/cli/doctor.ts +2 -0
- package/src/cli/fixtures/lessons-template-1.0.md +70 -0
- package/src/cli/init.test.ts +37 -24
- package/src/cli/layers.test.ts +2 -2
- package/src/cli/layers.ts +144 -14
- package/src/cli/legacy-install.test.ts +11 -1
- package/src/cli/lesson-command.test.ts +117 -0
- package/src/cli/lesson.ts +215 -266
- package/src/cli/lessons.test.ts +254 -0
- package/src/cli/lessons.ts +540 -0
- package/src/cli/pack-plugins.ts +70 -0
- package/src/cli/plugin-command.test.ts +125 -0
- package/src/cli/plugin.ts +309 -0
- package/src/cli/promote-command.test.ts +170 -0
- package/src/cli/promote.ts +371 -0
- package/src/cli/secret-scan.ts +154 -0
- package/src/cli/sync-check.ts +9 -0
- package/src/cli/team-commands.test.ts +2 -2
- package/src/cli/update.ts +20 -0
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/agents/researcher.agent.md +1 -1
- package/src/orchestrator/customizations/LESSONS-LEARNED.md +10 -66
- package/src/orchestrator/customizations/README.md +2 -1
- package/src/orchestrator/customizations/logs/README.md +1 -1
- package/src/orchestrator/plugins/agent-plugins.test.ts +34 -0
- package/src/orchestrator/plugins/astro/mcp.json +9 -0
- package/src/orchestrator/plugins/astro/plugin.json +21 -0
- package/src/orchestrator/plugins/chrome-devtools/mcp.json +13 -0
- package/src/orchestrator/plugins/chrome-devtools/plugin.json +21 -0
- package/src/orchestrator/plugins/cloudflare/mcp.json +9 -0
- package/src/orchestrator/plugins/cloudflare/plugin.json +21 -0
- package/src/orchestrator/plugins/contentful/mcp.json +13 -0
- package/src/orchestrator/plugins/contentful/plugin.json +21 -0
- package/src/orchestrator/plugins/convex/mcp.json +15 -0
- package/src/orchestrator/plugins/convex/plugin.json +21 -0
- package/src/orchestrator/plugins/coolify/mcp.json +13 -0
- package/src/orchestrator/plugins/coolify/plugin.json +25 -0
- package/src/orchestrator/plugins/cypress/plugin.json +21 -0
- package/src/orchestrator/plugins/drizzle/plugin.json +21 -0
- package/src/orchestrator/plugins/expo/mcp.json +9 -0
- package/src/orchestrator/plugins/expo/plugin.json +21 -0
- package/src/orchestrator/plugins/figma/mcp.json +9 -0
- package/src/orchestrator/plugins/figma/plugin.json +21 -0
- package/src/orchestrator/plugins/hetzner/plugin.json +24 -0
- package/src/orchestrator/plugins/jira/mcp.json +9 -0
- package/src/orchestrator/plugins/jira/plugin.json +21 -0
- package/src/orchestrator/plugins/linear/mcp.json +9 -0
- package/src/orchestrator/plugins/linear/plugin.json +21 -0
- package/src/orchestrator/plugins/netlify/mcp.json +13 -0
- package/src/orchestrator/plugins/netlify/plugin.json +21 -0
- package/src/orchestrator/plugins/nextjs/mcp.json +13 -0
- package/src/orchestrator/plugins/nextjs/plugin.json +21 -0
- package/src/orchestrator/plugins/notion/mcp.json +9 -0
- package/src/orchestrator/plugins/notion/plugin.json +21 -0
- package/src/orchestrator/plugins/nx/mcp.json +14 -0
- package/src/orchestrator/plugins/nx/plugin.json +21 -0
- package/src/orchestrator/plugins/playwright/mcp.json +13 -0
- package/src/orchestrator/plugins/playwright/plugin.json +21 -0
- package/src/orchestrator/plugins/prisma/mcp.json +14 -0
- package/src/orchestrator/plugins/prisma/plugin.json +21 -0
- package/src/orchestrator/plugins/resend/mcp.json +13 -0
- package/src/orchestrator/plugins/resend/plugin.json +24 -0
- package/src/orchestrator/plugins/sanity/mcp.json +9 -0
- package/src/orchestrator/plugins/sanity/plugin.json +21 -0
- package/src/orchestrator/plugins/sentry/mcp.json +12 -0
- package/src/orchestrator/plugins/sentry/plugin.json +24 -0
- package/src/orchestrator/plugins/slack/mcp.json +13 -0
- package/src/orchestrator/plugins/slack/plugin.json +24 -0
- package/src/orchestrator/plugins/strapi/mcp.json +13 -0
- package/src/orchestrator/plugins/strapi/plugin.json +21 -0
- package/src/orchestrator/plugins/stripe/mcp.json +9 -0
- package/src/orchestrator/plugins/stripe/plugin.json +21 -0
- package/src/orchestrator/plugins/supabase/mcp.json +9 -0
- package/src/orchestrator/plugins/supabase/plugin.json +21 -0
- package/src/orchestrator/plugins/teams/plugin.json +24 -0
- package/src/orchestrator/plugins/trello/mcp.json +13 -0
- package/src/orchestrator/plugins/trello/plugin.json +25 -0
- package/src/orchestrator/plugins/turborepo/plugin.json +21 -0
- package/src/orchestrator/plugins/vercel/mcp.json +9 -0
- package/src/orchestrator/plugins/vercel/plugin.json +21 -0
- package/src/orchestrator/plugins/vitest/plugin.json +21 -0
- package/src/orchestrator/skill-config-links.test.ts +2 -1
- package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +1 -1
- package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
- package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
- package/src/orchestrator/skills/memory-merger/SKILL.md +17 -21
- package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +44 -23
- package/src/orchestrator/skills/self-improvement/SKILL.md +30 -15
- /package/src/orchestrator/plugins/astro/{SKILL.md → skills/astro-framework/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/chrome-devtools/{SKILL.md → skills/browser-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/cloudflare/{SKILL.md → skills/cloudflare-platform/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/contentful/{SKILL.md → skills/contentful-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/convex/{SKILL.md → skills/convex-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/coolify/{SKILL.md → skills/coolify-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/cypress/{SKILL.md → skills/cypress-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/drizzle/{SKILL.md → skills/drizzle-orm/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/expo/{SKILL.md → skills/expo-development/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/figma/{SKILL.md → skills/figma-design/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/hetzner/{SKILL.md → skills/hetzner-cloud/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/jira/{SKILL.md → skills/jira-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/linear/{SKILL.md → skills/linear-task-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/netlify/{SKILL.md → skills/netlify-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/nextjs/{SKILL.md → skills/nextjs-framework/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/notion/{SKILL.md → skills/notion-knowledge-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/nx/{SKILL.md → skills/nx-workspace/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/playwright/{SKILL.md → skills/playwright-testing/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/prisma/{SKILL.md → skills/prisma-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/resend/{SKILL.md → skills/resend-email/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/sanity/{SKILL.md → skills/sanity-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/sentry/{SKILL.md → skills/sentry-monitoring/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/slack/{SKILL.md → skills/slack-notifications/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/strapi/{SKILL.md → skills/strapi-cms/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/stripe/{SKILL.md → skills/stripe-payments/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/supabase/{SKILL.md → skills/supabase-database/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/teams/{SKILL.md → skills/teams-notifications/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/trello/{SKILL.md → skills/trello-task-management/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/turborepo/{SKILL.md → skills/turborepo-monorepo/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/vercel/{SKILL.md → skills/vercel-deployment/SKILL.md} +0 -0
- /package/src/orchestrator/plugins/vitest/{SKILL.md → skills/vitest-testing/SKILL.md} +0 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
6
|
+
import { parse as parseYaml } from 'yaml';
|
|
7
|
+
import { checkSkill } from './agent-plugin.js';
|
|
8
|
+
import { LESSONS_DIR, newLessonId, readLessons, renderLesson, syncLessons, today } from './lessons.js';
|
|
9
|
+
import { scanForSecrets } from './secret-scan.js';
|
|
10
|
+
import { getOrchestratorRoot } from './copy.js';
|
|
11
|
+
import { c } from './prompt.js';
|
|
12
|
+
/**
|
|
13
|
+
* `opencastle promote`: what one person's assistant learned, made the team's.
|
|
14
|
+
*
|
|
15
|
+
* Knowledge starts personal. A developer writes a skill for their own
|
|
16
|
+
* assistant, or the assistant remembers a correction it was given — Claude
|
|
17
|
+
* Code's auto memory keeps those on one machine, in one person's home
|
|
18
|
+
* directory, and no teammate's agent ever sees them. Productboard's Spark
|
|
19
|
+
* draws the same line between personal and workspace skills, and makes the
|
|
20
|
+
* step between them an explicit promotion after the author has tried it.
|
|
21
|
+
*
|
|
22
|
+
* This is that step. A skill is checked against the Agent Skills spec and
|
|
23
|
+
* scanned for credentials, then copied into the team's sources — this
|
|
24
|
+
* repository's `.opencastle/`, or a baseline every repository extends — where
|
|
25
|
+
* the next sync compiles it into every assistant. A memory becomes a lesson
|
|
26
|
+
* file. Either way it lands as a change in the working tree, and the pull
|
|
27
|
+
* request that commits it is where the team says yes.
|
|
28
|
+
*/
|
|
29
|
+
const HELP = `
|
|
30
|
+
opencastle promote <skill|memory> [name|path] [options]
|
|
31
|
+
|
|
32
|
+
Make what one person's assistant learned the team's: copy it into the
|
|
33
|
+
team's sources, where the next sync compiles it into every assistant.
|
|
34
|
+
|
|
35
|
+
skill <name|path> A skill you use yourself, found by name in your personal
|
|
36
|
+
skill directories (~/.claude/skills, ~/.agents/skills,
|
|
37
|
+
~/.codex/skills, ~/.cursor/skills, ~/.copilot/skills) or
|
|
38
|
+
given as a path. It is checked against the Agent Skills
|
|
39
|
+
spec and for credentials, then copied to
|
|
40
|
+
.opencastle/skills/<name>/ — or with --to, into a
|
|
41
|
+
baseline or Agent Plugin every repository extends.
|
|
42
|
+
memory What Claude Code's auto memory learned in this
|
|
43
|
+
repository — each correction (feedback) and project note
|
|
44
|
+
— written as lessons in .opencastle/lessons/. Memories
|
|
45
|
+
about you, credentials, and ones already promoted are
|
|
46
|
+
left out; your home directory is written as ~.
|
|
47
|
+
|
|
48
|
+
Options:
|
|
49
|
+
--to <dir> skill: a baseline or Agent Plugin directory to put it in
|
|
50
|
+
--from <dir> memory: read memory files from this directory instead
|
|
51
|
+
--force skill: replace a team skill with the same name
|
|
52
|
+
--dry-run Say what would be written, and write nothing
|
|
53
|
+
--help, -h Show this help
|
|
54
|
+
`;
|
|
55
|
+
function fail(message) {
|
|
56
|
+
console.error(` ${c.red('✗')} ${message}`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
function flag(args, name) {
|
|
60
|
+
const at = args.indexOf(name);
|
|
61
|
+
if (at === -1)
|
|
62
|
+
return undefined;
|
|
63
|
+
const v = args[at + 1];
|
|
64
|
+
if (!v || v.startsWith('--'))
|
|
65
|
+
fail(`${name} needs a value`);
|
|
66
|
+
return v;
|
|
67
|
+
}
|
|
68
|
+
function home() {
|
|
69
|
+
return process.env.HOME || homedir();
|
|
70
|
+
}
|
|
71
|
+
function tilde(path) {
|
|
72
|
+
const h = home();
|
|
73
|
+
return path === h ? '~' : path.startsWith(`${h}/`) ? `~${path.slice(h.length)}` : path;
|
|
74
|
+
}
|
|
75
|
+
function projectRootFrom(cwd) {
|
|
76
|
+
let dir = cwd;
|
|
77
|
+
for (;;) {
|
|
78
|
+
if (existsSync(join(dir, '.opencastle')))
|
|
79
|
+
return dir;
|
|
80
|
+
const parent = dirname(dir);
|
|
81
|
+
if (parent === dir)
|
|
82
|
+
return cwd;
|
|
83
|
+
dir = parent;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Every file under a directory, relative to it. */
|
|
87
|
+
function filesIn(dir) {
|
|
88
|
+
const out = [];
|
|
89
|
+
const walk = (d, prefix) => {
|
|
90
|
+
for (const e of readdirSync(d, { withFileTypes: true })) {
|
|
91
|
+
if (e.isDirectory())
|
|
92
|
+
walk(join(d, e.name), `${prefix}${e.name}/`);
|
|
93
|
+
else if (e.isFile())
|
|
94
|
+
out.push(`${prefix}${e.name}`);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
walk(dir, '');
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
// ── skill ─────────────────────────────────────────────────────
|
|
101
|
+
/** Where assistants keep a person's own skills. */
|
|
102
|
+
export function personalSkillDirs() {
|
|
103
|
+
const h = home();
|
|
104
|
+
return ['.claude/skills', '.agents/skills', '.codex/skills', '.cursor/skills', '.copilot/skills'].map((d) => join(h, d));
|
|
105
|
+
}
|
|
106
|
+
function findSkill(ref, cwd) {
|
|
107
|
+
const asPath = resolve(cwd, ref.replace(/^~(?=\/|$)/, home()));
|
|
108
|
+
if (ref.includes('/') || ref.startsWith('.')) {
|
|
109
|
+
if (existsSync(join(asPath, 'SKILL.md')))
|
|
110
|
+
return asPath;
|
|
111
|
+
fail(`${ref} is not a skill directory — it has no SKILL.md`);
|
|
112
|
+
}
|
|
113
|
+
const found = personalSkillDirs().map((d) => join(d, ref)).filter((d) => existsSync(join(d, 'SKILL.md')));
|
|
114
|
+
if (found.length === 0) {
|
|
115
|
+
fail(`no skill named ${ref} in ${personalSkillDirs().map(tilde).join(', ')} — give its path instead`);
|
|
116
|
+
}
|
|
117
|
+
if (found.length > 1) {
|
|
118
|
+
const differ = new Set(found.map((d) => createHash('sha256').update(readFileSync(join(d, 'SKILL.md'))).digest('hex'))).size > 1;
|
|
119
|
+
if (differ)
|
|
120
|
+
fail(`${ref} is in ${found.map(tilde).join(' and ')}, and they differ — give the path of the one to promote`);
|
|
121
|
+
}
|
|
122
|
+
return found[0];
|
|
123
|
+
}
|
|
124
|
+
/** The `skills/` directory of a baseline or Agent Plugin. */
|
|
125
|
+
function skillsDirOf(target) {
|
|
126
|
+
const pkgFile = join(target, 'package.json');
|
|
127
|
+
if (existsSync(pkgFile)) {
|
|
128
|
+
try {
|
|
129
|
+
const baseline = JSON.parse(readFileSync(pkgFile, 'utf8')).opencastle?.baseline;
|
|
130
|
+
if (typeof baseline === 'string')
|
|
131
|
+
return join(resolve(target, baseline), 'skills');
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Not ours to judge here; the copy below names the directory it used.
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (existsSync(join(target, 'plugin.json')) || existsSync(join(target, 'config.json')))
|
|
138
|
+
return join(target, 'skills');
|
|
139
|
+
fail(`${target} is neither a baseline nor an Agent Plugin — it has no package.json declaring a baseline, no plugin.json and no config.json`);
|
|
140
|
+
}
|
|
141
|
+
function promoteSkill(pkgRoot, args, dryRun) {
|
|
142
|
+
const ref = args.find((a, i) => !a.startsWith('--') && !['--to', '--from'].includes(args[i - 1]));
|
|
143
|
+
if (!ref)
|
|
144
|
+
fail('promote skill needs the skill — its name, or the path to its directory');
|
|
145
|
+
const cwd = process.cwd();
|
|
146
|
+
const source = findSkill(ref, cwd);
|
|
147
|
+
const name = basename(source);
|
|
148
|
+
const skill = checkSkill(source);
|
|
149
|
+
if (skill.errors.length > 0) {
|
|
150
|
+
for (const e of skill.errors)
|
|
151
|
+
console.error(` ${c.red('✗')} ${e.replace(/^skills\//, `${tilde(dirname(source))}/`)}`);
|
|
152
|
+
fail('fix it where it is, then promote it — every assistant that follows the Agent Skills spec would skip it as it stands');
|
|
153
|
+
}
|
|
154
|
+
for (const w of skill.warnings)
|
|
155
|
+
console.log(` ${c.yellow('!')} ${c.dim(w)}`);
|
|
156
|
+
for (const rel of filesIn(source)) {
|
|
157
|
+
let text;
|
|
158
|
+
try {
|
|
159
|
+
text = readFileSync(join(source, rel), 'utf8');
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const scan = scanForSecrets(text, rel);
|
|
165
|
+
if (!scan.clean) {
|
|
166
|
+
const f = scan.findings[0];
|
|
167
|
+
fail(`${name}/${rel} line ${f.line} holds what looks like a ${f.pattern} — the team's sources are committed, so take it out first`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const to = flag(args, '--to');
|
|
171
|
+
const projectRoot = projectRootFrom(cwd);
|
|
172
|
+
const destSkills = to ? skillsDirOf(resolve(cwd, to)) : join(projectRoot, '.opencastle', 'skills');
|
|
173
|
+
if (!to && !existsSync(join(projectRoot, '.opencastle')))
|
|
174
|
+
fail('no .opencastle/ here — run opencastle init first, or promote it into a baseline with --to <dir>');
|
|
175
|
+
const dest = join(destSkills, name);
|
|
176
|
+
const shown = relative(cwd, dest) || '.';
|
|
177
|
+
if (existsSync(dest) && !args.includes('--force')) {
|
|
178
|
+
fail(`${shown} already exists — compare them, then pass --force to replace it`);
|
|
179
|
+
}
|
|
180
|
+
const core = existsSync(join(getOrchestratorRoot(pkgRoot), 'skills', name));
|
|
181
|
+
if (dryRun) {
|
|
182
|
+
console.log(` [dry-run] Would copy ${tilde(source)} to ${shown}/ (${filesIn(source).length} file(s))`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
mkdirSync(destSkills, { recursive: true });
|
|
186
|
+
cpSync(source, dest, { recursive: true, force: true });
|
|
187
|
+
console.log(`\n ${c.green('✓')} Promoted ${c.bold(name)} from ${tilde(source)} to ${shown}/`);
|
|
188
|
+
if (core)
|
|
189
|
+
console.log(` ${c.yellow('!')} OpenCastle ships a skill of that name; this one replaces it for everyone it reaches`);
|
|
190
|
+
console.log(to
|
|
191
|
+
? ` ${c.dim('Next:')} ${c.cyan(`opencastle baseline check ${relative(cwd, resolve(cwd, to)) || '.'}`)}${c.dim(', then publish a new version.')}\n`
|
|
192
|
+
: ` ${c.dim('Next:')} ${c.cyan('opencastle sync')} ${c.dim('compiles it into every assistant; commit it, and the pull request is where the team agrees.')}\n`);
|
|
193
|
+
}
|
|
194
|
+
// ── memory ────────────────────────────────────────────────────
|
|
195
|
+
/** The directory Claude Code's settings point auto memory at, if any of them does. */
|
|
196
|
+
function configuredMemoryDir(projectRoot, configDir) {
|
|
197
|
+
for (const file of [
|
|
198
|
+
join(projectRoot, '.claude', 'settings.local.json'),
|
|
199
|
+
join(projectRoot, '.claude', 'settings.json'),
|
|
200
|
+
join(configDir, 'settings.json'),
|
|
201
|
+
]) {
|
|
202
|
+
try {
|
|
203
|
+
const value = JSON.parse(readFileSync(file, 'utf8')).autoMemoryDirectory;
|
|
204
|
+
if (typeof value === 'string' && value)
|
|
205
|
+
return value.replace(/^~(?=\/|$)/, home());
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
// Absent or unreadable: the next one, or the default.
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Where Claude Code keeps this repository's auto memory:
|
|
215
|
+
* `<config>/projects/<repository path, every other character a hyphen>/memory/`.
|
|
216
|
+
* Every worktree of one repository shares it, so the path is the main
|
|
217
|
+
* checkout's, which git names as the common directory's parent.
|
|
218
|
+
*/
|
|
219
|
+
export function claudeMemoryDir(projectRoot) {
|
|
220
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || join(home(), '.claude');
|
|
221
|
+
const configured = configuredMemoryDir(projectRoot, configDir);
|
|
222
|
+
if (configured)
|
|
223
|
+
return configured;
|
|
224
|
+
let repo = projectRoot;
|
|
225
|
+
try {
|
|
226
|
+
const common = execFileSync('git', ['rev-parse', '--path-format=absolute', '--git-common-dir'], {
|
|
227
|
+
cwd: projectRoot,
|
|
228
|
+
encoding: 'utf8',
|
|
229
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
230
|
+
}).trim();
|
|
231
|
+
repo = basename(common) === '.git' ? dirname(common) : projectRoot;
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
repo = projectRoot;
|
|
235
|
+
}
|
|
236
|
+
const slug = process.env.CLAUDE_CODE_PROJECT_DIR_NAME || repo.replace(/[^A-Za-z0-9]/g, '-');
|
|
237
|
+
return join(configDir, 'projects', slug, 'memory');
|
|
238
|
+
}
|
|
239
|
+
function readMemories(dir) {
|
|
240
|
+
const out = [];
|
|
241
|
+
for (const file of readdirSync(dir).sort()) {
|
|
242
|
+
if (!file.endsWith('.md') || file === 'MEMORY.md')
|
|
243
|
+
continue;
|
|
244
|
+
const abs = join(dir, file);
|
|
245
|
+
if (!statSync(abs).isFile())
|
|
246
|
+
continue;
|
|
247
|
+
const text = readFileSync(abs, 'utf8').replace(/^\uFEFF/, '');
|
|
248
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(text);
|
|
249
|
+
let meta = {};
|
|
250
|
+
try {
|
|
251
|
+
meta = m ? (parseYaml(m[1]) ?? {}) : {};
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
meta = {};
|
|
255
|
+
}
|
|
256
|
+
const nested = meta.metadata && typeof meta.metadata === 'object' ? meta.metadata : {};
|
|
257
|
+
const type = typeof meta.type === 'string' ? meta.type : typeof nested.type === 'string' ? nested.type : undefined;
|
|
258
|
+
out.push({
|
|
259
|
+
file,
|
|
260
|
+
name: typeof meta.name === 'string' ? meta.name : file.replace(/\.md$/, ''),
|
|
261
|
+
description: typeof meta.description === 'string' ? meta.description : undefined,
|
|
262
|
+
type,
|
|
263
|
+
body: (m ? m[2] : text).trim(),
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
/** A title for a memory: its description, else its name read as words. */
|
|
269
|
+
function titleOf(memory) {
|
|
270
|
+
const raw = memory.description ?? memory.name.replace(/[-_]+/g, ' ');
|
|
271
|
+
const one = raw.replace(/[\r\n]+/g, ' ').trim();
|
|
272
|
+
return one.charAt(0).toUpperCase() + one.slice(1);
|
|
273
|
+
}
|
|
274
|
+
function promoteMemory(args, dryRun) {
|
|
275
|
+
const projectRoot = projectRootFrom(process.cwd());
|
|
276
|
+
const customizations = join(projectRoot, '.opencastle');
|
|
277
|
+
if (!existsSync(customizations))
|
|
278
|
+
fail('no .opencastle/ here — run opencastle init first');
|
|
279
|
+
const from = flag(args, '--from');
|
|
280
|
+
const dir = from ? resolve(process.cwd(), from.replace(/^~(?=\/|$)/, home())) : claudeMemoryDir(projectRoot);
|
|
281
|
+
if (!existsSync(dir)) {
|
|
282
|
+
fail(`no memory at ${tilde(dir)} — Claude Code keeps it there once it has saved one for this repository; --from <dir> reads another`);
|
|
283
|
+
}
|
|
284
|
+
syncLessons(customizations);
|
|
285
|
+
const { lessons } = readLessons(customizations);
|
|
286
|
+
const promoted = new Set(lessons.map((l) => l.source).filter((s) => Boolean(s)));
|
|
287
|
+
const taken = new Set(lessons.map((l) => l.id));
|
|
288
|
+
const written = [];
|
|
289
|
+
const skipped = [];
|
|
290
|
+
const h = home();
|
|
291
|
+
for (const memory of readMemories(dir)) {
|
|
292
|
+
if (memory.type && !['feedback', 'project'].includes(memory.type)) {
|
|
293
|
+
skipped.push([memory.file, memory.type === 'user' ? 'about you, not the project' : `a ${memory.type} memory`]);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (!memory.body) {
|
|
297
|
+
skipped.push([memory.file, 'empty']);
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const digest = createHash('sha256').update(memory.body).digest('hex').slice(0, 12);
|
|
301
|
+
const source = `claude-code-memory:${memory.file}#${digest}`;
|
|
302
|
+
if (promoted.has(source)) {
|
|
303
|
+
skipped.push([memory.file, 'already a lesson']);
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
// A memory names paths on its author's machine; the team's copy says ~.
|
|
307
|
+
const body = memory.body.split(h).join('~');
|
|
308
|
+
const scan = scanForSecrets(body, memory.file);
|
|
309
|
+
if (!scan.clean) {
|
|
310
|
+
skipped.push([memory.file, `holds what looks like a ${scan.findings[0].pattern} (line ${scan.findings[0].line})`]);
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
const title = titleOf(memory);
|
|
314
|
+
const id = newLessonId(title, today(), taken);
|
|
315
|
+
taken.add(id);
|
|
316
|
+
const lesson = {
|
|
317
|
+
id,
|
|
318
|
+
title,
|
|
319
|
+
category: 'general',
|
|
320
|
+
severity: 'medium',
|
|
321
|
+
added: today(),
|
|
322
|
+
citations: [],
|
|
323
|
+
status: 'active',
|
|
324
|
+
source,
|
|
325
|
+
body,
|
|
326
|
+
};
|
|
327
|
+
written.push(`${LESSONS_DIR}/${id}.md`);
|
|
328
|
+
if (!dryRun) {
|
|
329
|
+
mkdirSync(join(customizations, LESSONS_DIR), { recursive: true });
|
|
330
|
+
writeFileSync(join(customizations, LESSONS_DIR, `${id}.md`), renderLesson(lesson));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (!dryRun && written.length > 0)
|
|
334
|
+
syncLessons(customizations);
|
|
335
|
+
console.log(`\n 🏰 ${c.bold('Promote memory')} ${c.dim(`from ${tilde(dir)}`)}\n`);
|
|
336
|
+
if (written.length === 0)
|
|
337
|
+
console.log(` ${c.dim('Nothing new to promote.')}`);
|
|
338
|
+
for (const w of written)
|
|
339
|
+
console.log(` ${c.green(dryRun ? '+' : '✓')} ${dryRun ? 'Would write' : 'Wrote'} .opencastle/${w}`);
|
|
340
|
+
for (const [file, why] of skipped)
|
|
341
|
+
console.log(` ${c.dim(`- ${file}: ${why}`)}`);
|
|
342
|
+
if (written.length > 0 && !dryRun) {
|
|
343
|
+
console.log(`\n ${c.dim('Each is category general, severity medium: set them, add --cite where a lesson is about code,')}` +
|
|
344
|
+
`\n ${c.dim('and delete any that are yours alone. The pull request that commits them is where the team agrees.')}\n`);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
console.log('');
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
export default async function promote({ pkgRoot, args }) {
|
|
351
|
+
const [sub, ...rest] = args;
|
|
352
|
+
if (!sub || args.includes('--help') || args.includes('-h') || !['skill', 'memory'].includes(sub)) {
|
|
353
|
+
console.log(HELP);
|
|
354
|
+
if (sub && !['skill', 'memory', '--help', '-h'].includes(sub))
|
|
355
|
+
process.exit(1);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const dryRun = rest.includes('--dry-run');
|
|
359
|
+
if (sub === 'skill')
|
|
360
|
+
promoteSkill(pkgRoot, rest, dryRun);
|
|
361
|
+
else
|
|
362
|
+
promoteMemory(rest, dryRun);
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=promote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promote.js","sourceRoot":"","sources":["../../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,EAAE,OAAO,EAAE,IAAI,EAAc;IACjE,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IAC3B,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACjG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjB,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC9E,OAAM;IACR,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACzC,IAAI,GAAG,KAAK,OAAO;QAAE,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;;QACnD,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAClC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SecretScanResult {
|
|
2
|
+
clean: boolean;
|
|
3
|
+
findings: Array<{
|
|
4
|
+
pattern: string;
|
|
5
|
+
file: string;
|
|
6
|
+
line: number;
|
|
7
|
+
snippet: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
/** The config path used for the allowlist. Override for testing. */
|
|
11
|
+
export declare let _allowlistConfigPath: string;
|
|
12
|
+
/** Reset the allowlist cache (for testing). */
|
|
13
|
+
export declare function _resetAllowlistCache(): void;
|
|
14
|
+
/** Override the allowlist config path and reset cache (for testing). */
|
|
15
|
+
export declare function _setAllowlistConfigPath(path: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Scan text content line-by-line for secrets using the default pattern set.
|
|
18
|
+
* Allowlist entries in `.opencastle/secret-scan-config.yml` suppress false positives.
|
|
19
|
+
*/
|
|
20
|
+
export declare function scanForSecrets(content: string, filePath?: string): SecretScanResult;
|
|
21
|
+
//# sourceMappingURL=secret-scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-scan.d.ts","sourceRoot":"","sources":["../../src/cli/secret-scan.ts"],"names":[],"mappings":"AAqDA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAClF;AAaD,oEAAoE;AACpE,eAAO,IAAI,oBAAoB,QAA+D,CAAA;AAE9F,+CAA+C;AAC/C,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,wEAAwE;AACxE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAG1D;AA+CD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAK,GAAG,gBAAgB,CAqB/E"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { parse as yamlParse } from 'yaml';
|
|
4
|
+
const SECRET_PATTERNS = [
|
|
5
|
+
{ name: 'AWS Access Key', pattern: /AKIA[0-9A-Z]{16}/i },
|
|
6
|
+
{
|
|
7
|
+
name: 'AWS Secret Key',
|
|
8
|
+
// eslint-disable-next-line no-useless-escape
|
|
9
|
+
pattern: /(?:aws_secret_access_key|secret_key)\s*[=:]\s*[A-Za-z0-9\/+=]{40}/i,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'Generic API Key',
|
|
13
|
+
pattern: /(?:api[_-]?key|apikey)\s*[=:]\s*['"]?[A-Za-z0-9_-]{20,}/i,
|
|
14
|
+
},
|
|
15
|
+
{ name: 'Bearer Token', pattern: /[Bb]earer\s+[A-Za-z0-9\-._~+/]+=*/ },
|
|
16
|
+
{ name: 'Private Key', pattern: /-----BEGIN (?:RSA|EC|OPENSSH) PRIVATE KEY-----/ },
|
|
17
|
+
{
|
|
18
|
+
name: 'Connection String',
|
|
19
|
+
// eslint-disable-next-line no-useless-escape
|
|
20
|
+
pattern: /(?:postgres|mysql|mongodb|redis):\/\/[^\s]+:[^\s]+@/,
|
|
21
|
+
},
|
|
22
|
+
{ name: 'GitHub Token', pattern: /(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{36,}/ },
|
|
23
|
+
{
|
|
24
|
+
name: 'Generic Password',
|
|
25
|
+
pattern: /(?:password|passwd|pwd)\s*[=:]\s*['"]?[^\s'"]{8,}/i,
|
|
26
|
+
},
|
|
27
|
+
{ name: 'Slack Token', pattern: /xox[bprs]-[A-Za-z0-9-]{10,}/i },
|
|
28
|
+
{
|
|
29
|
+
name: 'Generic Secret',
|
|
30
|
+
pattern: /(?:secret|token|credential)\s*[=:]\s*['"]?[A-Za-z0-9_-]{16,}/i,
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
let _allowlist = null;
|
|
34
|
+
/** The config path used for the allowlist. Override for testing. */
|
|
35
|
+
export let _allowlistConfigPath = join(process.cwd(), '.opencastle', 'secret-scan-config.yml');
|
|
36
|
+
/** Reset the allowlist cache (for testing). */
|
|
37
|
+
export function _resetAllowlistCache() {
|
|
38
|
+
_allowlist = null;
|
|
39
|
+
}
|
|
40
|
+
/** Override the allowlist config path and reset cache (for testing). */
|
|
41
|
+
export function _setAllowlistConfigPath(path) {
|
|
42
|
+
_allowlistConfigPath = path;
|
|
43
|
+
_allowlist = null;
|
|
44
|
+
}
|
|
45
|
+
function loadAllowlist() {
|
|
46
|
+
if (_allowlist !== null)
|
|
47
|
+
return _allowlist;
|
|
48
|
+
try {
|
|
49
|
+
if (!existsSync(_allowlistConfigPath)) {
|
|
50
|
+
_allowlist = [];
|
|
51
|
+
return _allowlist;
|
|
52
|
+
}
|
|
53
|
+
const content = readFileSync(_allowlistConfigPath, 'utf-8');
|
|
54
|
+
const parsed = yamlParse(content);
|
|
55
|
+
if (!parsed || !Array.isArray(parsed['allowlist'])) {
|
|
56
|
+
_allowlist = [];
|
|
57
|
+
return _allowlist;
|
|
58
|
+
}
|
|
59
|
+
_allowlist = parsed['allowlist'];
|
|
60
|
+
return _allowlist;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
_allowlist = [];
|
|
64
|
+
return _allowlist;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function isSuppressed(finding, filePath, allowlist) {
|
|
68
|
+
for (const entry of allowlist) {
|
|
69
|
+
if (entry.paths && entry.paths.length > 0) {
|
|
70
|
+
if (!entry.paths.some((p) => filePath.includes(p)))
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (entry.literal) {
|
|
74
|
+
if (finding.snippet.includes(entry.literal))
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
else if (entry.pattern) {
|
|
78
|
+
try {
|
|
79
|
+
if (new RegExp(entry.pattern, 'i').test(finding.snippet))
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// Invalid regex in allowlist — skip entry
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
// ── scanForSecrets ────────────────────────────────────────────────────────────
|
|
90
|
+
/**
|
|
91
|
+
* Scan text content line-by-line for secrets using the default pattern set.
|
|
92
|
+
* Allowlist entries in `.opencastle/secret-scan-config.yml` suppress false positives.
|
|
93
|
+
*/
|
|
94
|
+
export function scanForSecrets(content, filePath = '') {
|
|
95
|
+
const allowlist = loadAllowlist();
|
|
96
|
+
const lines = content.split('\n');
|
|
97
|
+
const findings = [];
|
|
98
|
+
for (let i = 0; i < lines.length; i++) {
|
|
99
|
+
const line = lines[i];
|
|
100
|
+
for (const { name, pattern } of SECRET_PATTERNS) {
|
|
101
|
+
if (pattern.test(line)) {
|
|
102
|
+
const snippet = line.length > 100 ? line.slice(0, 97) + '...' : line;
|
|
103
|
+
const finding = { pattern: name, file: filePath, line: i + 1, snippet };
|
|
104
|
+
if (!isSuppressed(finding, filePath, allowlist)) {
|
|
105
|
+
findings.push(finding);
|
|
106
|
+
}
|
|
107
|
+
// Only report the first matching pattern per line
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { clean: findings.length === 0, findings };
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=secret-scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-scan.js","sourceRoot":"","sources":["../../src/cli/secret-scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAA;AAmBzC,MAAM,eAAe,GAAyB;IAC5C,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,EAAE;IACxD;QACE,IAAI,EAAE,gBAAgB;QACtB,6CAA6C;QAC7C,OAAO,EAAE,oEAAoE;KAC9E;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,0DAA0D;KACpE;IACD,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,mCAAmC,EAAE;IACtE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,gDAAgD,EAAE;IAClF;QACE,IAAI,EAAE,mBAAmB;QACzB,6CAA6C;QAC7C,OAAO,EAAE,qDAAqD;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AC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACrB,KAAK,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,eAAe,EAAE,CAAC;YAChD,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;gBACpE,MAAM,OAAO,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,CAAA;gBACvE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;oBAChD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBACxB,CAAC;gBACD,kDAAkD;gBAClD,MAAK;YACP,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;AACnD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-check.d.ts","sourceRoot":"","sources":["../../src/cli/sync-check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-check.d.ts","sourceRoot":"","sources":["../../src/cli/sync-check.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,UAAU,EAA0B,MAAM,YAAY,CAAA;AAEpE;;;;;;;;GAQG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,CAAA;AAEpF,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,SAAS,CAAA;IACf;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAA;IACnC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,KAAK,EAAE,KAAK,EAAE,CAAA;IACd,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAA;CAChB;AA0LD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAiEjG;AA2cD,2CAA2C;AAC3C,wBAAsB,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAwC3E"}
|
package/dist/cli/sync-check.js
CHANGED
|
@@ -6,6 +6,7 @@ import { IDE_ADAPTERS } from './adapters/index.js';
|
|
|
6
6
|
import { detectRepoInfo, mergeStackIntoRepoInfo } from './detect.js';
|
|
7
7
|
import { getMcpConfigRelPath, expectedTeamEntries, containerKeyFor } from './mcp.js';
|
|
8
8
|
import { parseMcpConfigText } from './mcp-file.js';
|
|
9
|
+
import { lessonsIndexDrift, LESSONS_INDEX } from './lessons.js';
|
|
9
10
|
import { resolveStack, getIncludedMcpServers } from './stack-config.js';
|
|
10
11
|
import { auditMcpConfig, describeFindingUnder, remedyFor, isFailure } from './mcp-audit.js';
|
|
11
12
|
import { resolveSources, materialize, hasErrors, cliVersionOf } from './layers.js';
|
|
@@ -584,6 +585,14 @@ async function compareProject(pkgRoot, projectRoot, ides, stack, repoInfo, sourc
|
|
|
584
585
|
}
|
|
585
586
|
}
|
|
586
587
|
}
|
|
588
|
+
// The lessons index, compiled from `.opencastle/lessons/` by `sync`. Two
|
|
589
|
+
// branches that each add a lesson merge cleanly; the index they both touched
|
|
590
|
+
// is what this catches, and `sync` rebuilds it.
|
|
591
|
+
{
|
|
592
|
+
const why = lessonsIndexDrift(resolve(projectRoot, '.opencastle'));
|
|
593
|
+
if (why)
|
|
594
|
+
drift.push({ ide: 'all', path: `.opencastle/${LESSONS_INDEX}`, kind: 'outdated', detail: why, fix: 'opencastle sync' });
|
|
595
|
+
}
|
|
587
596
|
// A manifest that parses but names no target this release knows is not a
|
|
588
597
|
// clean project — `sync` exits 1 on it. Reporting "0 generated files match
|
|
589
598
|
// their sources across 0 targets" is an assertion that cannot fail, and it
|