@sayknow-cli/coding-agent 0.7.21 → 0.7.22
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 +11 -1
- package/dist/types/config/settings-schema.d.ts +17 -0
- package/dist/types/defaults/skc-security-skills.d.ts +13 -0
- package/dist/types/hooks/security-skill-keywords.d.ts +21 -0
- package/package.json +7 -7
- package/src/cli/skills-cli.ts +11 -10
- package/src/config/settings-schema.ts +20 -0
- package/src/defaults/skc/security-skills/LICENSE.usestrix +201 -0
- package/src/defaults/skc/security-skills/NOTICE.md +47 -0
- package/src/defaults/skc/security-skills/security-review/SKILL.md +854 -0
- package/src/defaults/skc-security-skills.ts +42 -0
- package/src/extensibility/runtime-skill-discovery.ts +6 -1
- package/src/hooks/native-skill-hook.ts +3 -0
- package/src/hooks/security-skill-keywords.ts +66 -0
- package/src/internal-urls/docs-index.generated.ts +3 -3
- package/src/prompts/system/system-prompt.md +1 -0
- package/src/prompts/tools/skill.md +1 -1
- package/src/sdk/session.ts +11 -6
- package/src/session/agent-session.ts +34 -14
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { parseFrontmatter } from "@sayknow-cli/utils";
|
|
2
|
+
import type { Skill } from "../extensibility/skills";
|
|
3
|
+
import securityReviewSkill from "./skc/security-skills/security-review/SKILL.md" with { type: "text" };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Bundled security review skill. Like the UI craft skills it is NOT a public
|
|
7
|
+
* SKC workflow skill: the four public workflows remain deep-interview, ralplan,
|
|
8
|
+
* ultragoal, and team.
|
|
9
|
+
*
|
|
10
|
+
* The source and deliberate exclusions are documented in
|
|
11
|
+
* `skc/security-skills/NOTICE.md`; regenerate with `scripts/build-ui-skill-bundle.ts`.
|
|
12
|
+
*/
|
|
13
|
+
export const BUNDLED_SKC_SECURITY_SKILL_NAMES = ["security-review"] as const;
|
|
14
|
+
|
|
15
|
+
export type BundledSkcSecuritySkillName = (typeof BUNDLED_SKC_SECURITY_SKILL_NAMES)[number];
|
|
16
|
+
|
|
17
|
+
const BUNDLED_SECURITY_SKILL_CONTENT: Record<BundledSkcSecuritySkillName, string> = {
|
|
18
|
+
"security-review": securityReviewSkill,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function getEmbeddedSkcSecuritySkills(): Skill[] {
|
|
22
|
+
return BUNDLED_SKC_SECURITY_SKILL_NAMES.map(name => {
|
|
23
|
+
const content = BUNDLED_SECURITY_SKILL_CONTENT[name];
|
|
24
|
+
const filePath = `embedded:skc/security-skills/${name}/SKILL.md`;
|
|
25
|
+
const { frontmatter } = parseFrontmatter(content, { source: filePath, level: "warn" });
|
|
26
|
+
return {
|
|
27
|
+
name,
|
|
28
|
+
description:
|
|
29
|
+
typeof frontmatter.description === "string" ? frontmatter.description : `SKC security skill ${name}`,
|
|
30
|
+
filePath,
|
|
31
|
+
baseDir: `embedded:skc/security-skills/${name}`,
|
|
32
|
+
source: "bundled:security",
|
|
33
|
+
hide: false,
|
|
34
|
+
content,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function withEmbeddedSkcSecuritySkills(skills: Skill[]): Skill[] {
|
|
40
|
+
const names = new Set(skills.map(skill => skill.name));
|
|
41
|
+
return [...skills, ...getEmbeddedSkcSecuritySkills().filter(skill => !names.has(skill.name))];
|
|
42
|
+
}
|
|
@@ -4,6 +4,7 @@ import * as path from "node:path";
|
|
|
4
4
|
import { findRepoRoot } from "../capability/fs";
|
|
5
5
|
import type { Skill as CapabilitySkill } from "../capability/skill";
|
|
6
6
|
import type { SkillsSettings } from "../config/settings-schema";
|
|
7
|
+
import { BUNDLED_SKC_SECURITY_SKILL_NAMES } from "../defaults/skc-security-skills";
|
|
7
8
|
import { BUNDLED_SKC_UI_SKILL_NAMES } from "../defaults/skc-ui-skills";
|
|
8
9
|
import { compareSkillOrder, SOURCE_PATHS, scanSkillsFromDir } from "../discovery/helpers";
|
|
9
10
|
import { CANONICAL_SKC_WORKFLOW_SKILLS } from "../skill-state/canonical-skills";
|
|
@@ -34,7 +35,11 @@ function getRuntimeHome(): string {
|
|
|
34
35
|
|
|
35
36
|
const DEFAULT_LIMIT = 20;
|
|
36
37
|
const MAX_LIMIT = 50;
|
|
37
|
-
const BUILT_IN_SKILL_NAMES = new Set<string>([
|
|
38
|
+
const BUILT_IN_SKILL_NAMES = new Set<string>([
|
|
39
|
+
...CANONICAL_SKC_WORKFLOW_SKILLS,
|
|
40
|
+
...BUNDLED_SKC_UI_SKILL_NAMES,
|
|
41
|
+
...BUNDLED_SKC_SECURITY_SKILL_NAMES,
|
|
42
|
+
]);
|
|
38
43
|
|
|
39
44
|
function normalizeLimit(limit: number | undefined): number {
|
|
40
45
|
if (limit === undefined || !Number.isFinite(limit)) return DEFAULT_LIMIT;
|
|
@@ -10,6 +10,7 @@ import type { PromptTriager } from "../decisions/prompt-triage";
|
|
|
10
10
|
import { sessionLogsDir } from "../skc-runtime/session-layout";
|
|
11
11
|
import { trustedCoordinatorEnv } from "../skc-runtime/sidecar-bootstrap-env";
|
|
12
12
|
import { routeNativePrompt } from "./native-prompt-routing";
|
|
13
|
+
import { buildSecuritySkillActivationContext } from "./security-skill-keywords";
|
|
13
14
|
import {
|
|
14
15
|
buildActiveUltragoalPromptContext,
|
|
15
16
|
buildSkillActivationAdditionalContext,
|
|
@@ -316,6 +317,7 @@ async function dispatchSkcNativeSkillHookInner(
|
|
|
316
317
|
// Compute the bundled UI-skill directive first so a later state/recovery
|
|
317
318
|
// lookup cannot abort the turn without it.
|
|
318
319
|
const uiSkillContext = buildUiSkillActivationContext(prompt);
|
|
320
|
+
const securitySkillContext = buildSecuritySkillActivationContext(prompt);
|
|
319
321
|
let externalUiContext: string | null = null;
|
|
320
322
|
try {
|
|
321
323
|
externalUiContext = await buildExternalUiSkillContext({
|
|
@@ -409,6 +411,7 @@ async function dispatchSkcNativeSkillHookInner(
|
|
|
409
411
|
skillState ? buildSkillActivationAdditionalContext(skillState, effectiveSkillConfig) : activeUltragoalContext,
|
|
410
412
|
uiSkillContext ?? semanticUiContext,
|
|
411
413
|
externalUiContext,
|
|
414
|
+
securitySkillContext,
|
|
412
415
|
recoveryContext,
|
|
413
416
|
classifyQuestionOnlyPrompt(prompt),
|
|
414
417
|
]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic routing for the bundled security review skill (see
|
|
3
|
+
* `defaults/skc-security-skills.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Same shape as the UI skill routing in `ui-skill-keywords.ts`: a matching
|
|
6
|
+
* prompt gets a directive naming the skill to load for this turn, and no
|
|
7
|
+
* workflow state is seeded. The pattern is deliberately narrow. A miss costs
|
|
8
|
+
* nothing, because the system prompt still names the skill, while a wrong match
|
|
9
|
+
* loads a 40 KB review method onto unrelated work.
|
|
10
|
+
*
|
|
11
|
+
* Patterns cover every language SKC ships a UI for; other languages still reach
|
|
12
|
+
* the skill through the system prompt's routing rule.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { BundledSkcSecuritySkillName } from "../defaults/skc-security-skills";
|
|
16
|
+
|
|
17
|
+
const SECURITY_REVIEW_SKILL = "security-review" satisfies BundledSkcSecuritySkillName;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Review intent or a vulnerability, never the bare word "security": "update the
|
|
21
|
+
* security group" and "secure cookie flag" are ordinary implementation work.
|
|
22
|
+
*
|
|
23
|
+
* One entry per language in `SUPPORTED_LANGUAGES` (`i18n/index.ts`). `\b` is
|
|
24
|
+
* ASCII-only in JS, so no entry puts it next to an accented or CJK character.
|
|
25
|
+
*/
|
|
26
|
+
const SECURITY_REVIEW_PATTERNS: readonly RegExp[] = [
|
|
27
|
+
// en
|
|
28
|
+
/\bsecurity[- ](review|audit|scan|check|assessment|analysis|test(ing)?)\b|\b(review|audit|scan|analy[sz]e|assess)\b[^.?!]{0,40}\bsecurity\b|\bsecurity (issue|hole|flaw|bug|risk|problem)s?\b/,
|
|
29
|
+
// "vulnerability" in en, fr, it, es and pt, plus tool and standard names that are the same everywhere.
|
|
30
|
+
/\bvuln[eé]rabilit(y|ies|[eé]s?|à)|\bvulnerabilidad(es?)?|\b(owasp|sast|pen[- ]?test(ing|s)?|penetration[- ]test(ing|s)?|strix)\b/,
|
|
31
|
+
// ko
|
|
32
|
+
/보안\s*(검사|점검|리뷰|검토|감사|진단|스캔|분석|테스트|체크|이슈|문제|결함|구멍|허점)|취약점|모의\s*해킹|침투\s*테스트|스트릭스/,
|
|
33
|
+
// ja
|
|
34
|
+
/セキュリティ(の|を|上の)?\s*(レビュー|監査|診断|チェック|テスト|スキャン|検査|点検|分析|評価|問題|ホール)|脆弱性|ペネトレーション\s*テスト|ペンテスト|侵入テスト/,
|
|
35
|
+
// zh, simplified and traditional. 类型安全 and 线程安全 are type and thread safety, not security.
|
|
36
|
+
/(?<!类型|類型|线程|線程|執行緒)安全性?\s*(审查|审计|审核|检查|检测|测试|扫描|评估|分析|隐患|審查|審計|審核|檢查|檢測|測試|掃描|評估|隱患)|漏洞|渗透测试|滲透測試/,
|
|
37
|
+
// es ("copia de seguridad" is a backup, so the noun before "de seguridad" is required)
|
|
38
|
+
/\b(revisi[oó]n|auditor[ií]a|an[aá]lisis|escaneo|pruebas?|evaluaci[oó]n|fallos?|problemas?|brechas?|agujeros?)\s+de\s+seguridad\b|\bpruebas?\s+de\s+penetraci[oó]n/,
|
|
39
|
+
// fr
|
|
40
|
+
/\b(revue|audit|analyse|scan|tests?|v[eé]rification|examen|failles?|probl[eè]mes?)\s+de\s+s[eé]curit[eé]|\btests?\s+d['’]intrusion/,
|
|
41
|
+
// de
|
|
42
|
+
/\bsicherheits[- ]?(([uü]|ue)berpr[uü]fung|pr[uü]fung|audit|analyse|tests?|check|scan|review|l[uü]cken?|probleme?|bewertung)|\bschwachstelle|\bpenetrationstest/,
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const SECURITY_REVIEW_PATTERN = new RegExp(SECURITY_REVIEW_PATTERNS.map(pattern => pattern.source).join("|"), "i");
|
|
46
|
+
|
|
47
|
+
/** The matched phrase, or null when the prompt is not security review work. */
|
|
48
|
+
export function detectSecurityReviewKeyword(text: string): string | null {
|
|
49
|
+
return text.match(SECURITY_REVIEW_PATTERN)?.[0] ?? null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Build the `UserPromptSubmit` directive that makes the agent load the bundled
|
|
54
|
+
* security review skill for this turn. Returns null when the prompt is not
|
|
55
|
+
* security review work.
|
|
56
|
+
*/
|
|
57
|
+
export function buildSecuritySkillActivationContext(text: string): string | null {
|
|
58
|
+
const keyword = detectSecurityReviewKeyword(text);
|
|
59
|
+
if (!keyword) return null;
|
|
60
|
+
return [
|
|
61
|
+
`SKC detected security review work in this prompt (matched "${keyword}").`,
|
|
62
|
+
`Before reviewing or fixing, load \`${SECURITY_REVIEW_SKILL}\` with the \`skill\` tool and follow its scope rules: review only code the user owns or is authorized to assess, stay read-only unless a fix was requested, and never send test input to a system you were not told to test.`,
|
|
63
|
+
"The skill is bundled with SKC: never tell the user to install it.",
|
|
64
|
+
"It is not a workflow skill and has no `skc state` mode state.",
|
|
65
|
+
].join(" ");
|
|
66
|
+
}
|