@sayknow-cli/coding-agent 0.7.21 → 0.7.23
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 +17 -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/dist/types/utils/mupdf-wasm.d.ts +1 -1
- 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
- package/src/utils/mupdf-wasm.ts +12 -4
|
@@ -27,6 +27,7 @@ Optimize for correctness first, maintainability second, and brevity third. Prefe
|
|
|
27
27
|
- Use `/skill:ultragoal` for durable goal ledgers and `/skill:team` for approved coordinated persistent work.
|
|
28
28
|
- Delegate large implementation slices to `executor`; use `planner`, `architect`, or `critic` for bounded planning and review.
|
|
29
29
|
- Frontend UI/UX work (web, dashboard, mobile web, native app screens, animation, visual polish, component craft, faux product UI) MUST invoke `stageshow` first — the design center for every frontend surface, real product UI included — and then the matching bundled UI skill before writing or reviewing that surface: `emil-design-eng` for general UI/UX, `impeccable` for steering or evaluating a design (polish, bolder/quieter, distill, typography, color, layout, critique, audit), `motionsites-web-builder` for landing pages, marketing sites, cinematic heroes and Lovable/Bolt/v0 build prompts, `animate` for new motion, `review-animations` / `improve-animations` / `find-animation-opportunities` for motion review/audit/opportunity, `pick-ui-library` for library choice, `prototype` for variant exploration, `mobile-native` for phone-web native feel, `appllama-app-design-skill` for native Expo/React Native app screens, `ask-sonner` for Sonner toasts, `apple-design` for Apple-style motion/materials, `animation-vocabulary` for naming a motion effect. These are bundled; do not ask the user to install them. They are not workflow skills and do not use `skc state`.
|
|
30
|
+
- Security review work (a security review or audit, a vulnerability check, or a fix for a security issue in the user's code) MUST invoke the bundled `security-review` skill before reviewing or fixing. 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. It is bundled; do not ask the user to install it. It is not a workflow skill and does not use `skc state`.
|
|
30
31
|
- Active skills are authoritative: never ignore an invoked skill; read the full skill text and follow it exactly.
|
|
31
32
|
- Before explicit execution approval, planning and interview workflows NEVER edit product source, run mutating shell commands, commit, push, open PRs, or delegate implementation.
|
|
32
33
|
</routing>
|
|
@@ -6,7 +6,7 @@ Invoke another available skill in the current turn.
|
|
|
6
6
|
</conditions>
|
|
7
7
|
|
|
8
8
|
<instruction>
|
|
9
|
-
- `name` is the skill name as it appears in `/skill:<name>` (e.g. `ralplan`, `ultragoal`, `team`, `deep-interview`,
|
|
9
|
+
- `name` is the skill name as it appears in `/skill:<name>` (e.g. `ralplan`, `ultragoal`, `team`, `deep-interview`, a bundled UI skill such as `emil-design-eng`, or `security-review`)
|
|
10
10
|
- `args` is the free-form argument string the skill would receive after `/skill:<name>` on the command line
|
|
11
11
|
- The tool loads the callee's SKILL.md into the current turn and handles native workflow caller→callee state handoff when the caller is one of the built-in SKC workflows.
|
|
12
12
|
- The chain is refused while a native workflow caller is still active. If your current skill is one of `deep-interview`, `ralplan`, `ultragoal`, or `team` and has not yet reached a terminal phase, prepare it first with `skc state <skill> write --input '{"current_phase":"handoff"}' --json`; no other handoff command is needed. Bundled UI skills and runtime project/user skills do not use `skc state <skill>`.
|
package/src/sdk/session.ts
CHANGED
|
@@ -54,6 +54,7 @@ import type { BashRestrictionProfile } from "../tools/bash-allowed-prefixes";
|
|
|
54
54
|
import "../discovery";
|
|
55
55
|
import { getEmbeddedDefaultSkcSkills } from "../defaults/skc-defaults";
|
|
56
56
|
import { BUNDLED_GROK_BUILD_EXTENSION_ID, getBundledGrokBuildExtensionFactory } from "../defaults/skc-grok-cli";
|
|
57
|
+
import { withEmbeddedSkcSecuritySkills } from "../defaults/skc-security-skills";
|
|
57
58
|
import { withEmbeddedSkcUiSkills } from "../defaults/skc-ui-skills";
|
|
58
59
|
import { initializeWithSettings } from "../discovery";
|
|
59
60
|
import { disposeAllVmContexts, disposeVmContextsByOwner } from "../eval/js/context-manager";
|
|
@@ -915,7 +916,7 @@ function withEmbeddedDefaultSkcSkills(skills: Skill[]): Skill[] {
|
|
|
915
916
|
byName.set(defaultSkill.name, defaultSkill);
|
|
916
917
|
}
|
|
917
918
|
}
|
|
918
|
-
return withEmbeddedSkcUiSkills([...byName.values()]);
|
|
919
|
+
return withEmbeddedSkcSecuritySkills(withEmbeddedSkcUiSkills([...byName.values()]));
|
|
919
920
|
}
|
|
920
921
|
|
|
921
922
|
export function resolveIntentTracingEnabled(intentTracingSetting: boolean | undefined, hasUI: boolean): boolean {
|
|
@@ -1319,11 +1320,11 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1319
1320
|
skills = withEmbeddedDefaultSkcSkills(skillsResult.skills);
|
|
1320
1321
|
skillWarnings = skillsResult.warnings;
|
|
1321
1322
|
} else {
|
|
1322
|
-
// SKC's four public workflow skills plus bundled UI craft
|
|
1323
|
-
// compiled into the binary so the default
|
|
1324
|
-
// .skc deletion. Arbitrary filesystem skill
|
|
1325
|
-
// skills.enabled above.
|
|
1326
|
-
skills =
|
|
1323
|
+
// SKC's four public workflow skills plus the bundled UI craft and
|
|
1324
|
+
// security review skills are compiled into the binary so the default
|
|
1325
|
+
// surface survives accidental .skc deletion. Arbitrary filesystem skill
|
|
1326
|
+
// discovery remains gated by skills.enabled above.
|
|
1327
|
+
skills = withEmbeddedDefaultSkcSkills([]);
|
|
1327
1328
|
skillWarnings = [];
|
|
1328
1329
|
}
|
|
1329
1330
|
|
|
@@ -2481,6 +2482,9 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2481
2482
|
: serviceTierSetting === "none"
|
|
2482
2483
|
? undefined
|
|
2483
2484
|
: serviceTierSetting;
|
|
2485
|
+
const taskCacheRetention = settings.get("task.cacheRetention");
|
|
2486
|
+
const subagentCacheRetention =
|
|
2487
|
+
isCanonicalSubSession && taskCacheRetention !== "inherit" ? taskCacheRetention : undefined;
|
|
2484
2488
|
|
|
2485
2489
|
const appendOnlyContext =
|
|
2486
2490
|
model && resolveAppendOnlyMode(settings.get("provider.appendOnlyContext"), model.provider)
|
|
@@ -2558,6 +2562,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2558
2562
|
streamFn: (streamModel, context, streamOptions) =>
|
|
2559
2563
|
streamSimple(streamModel, context, {
|
|
2560
2564
|
...streamOptions,
|
|
2565
|
+
...(subagentCacheRetention ? { cacheRetention: subagentCacheRetention } : {}),
|
|
2561
2566
|
onAuthError: async (provider, oldKey, error) => {
|
|
2562
2567
|
// Invalidation (a broker forced refresh) and the re-fetch share the step's admission.
|
|
2563
2568
|
const credentialOptions = {
|
|
@@ -76,6 +76,7 @@ import {
|
|
|
76
76
|
estimateToolOutputPruneSavings,
|
|
77
77
|
pruneAssistantToolArguments,
|
|
78
78
|
pruneToolOutputs,
|
|
79
|
+
shouldPruneAtThreshold,
|
|
79
80
|
shouldRunMaintenancePrune,
|
|
80
81
|
} from "@sayknow-cli/agent-core/compaction/pruning";
|
|
81
82
|
import type {
|
|
@@ -280,6 +281,7 @@ import { expandSlashCommand, type FileSlashCommand } from "../extensibility/slas
|
|
|
280
281
|
import { GoalRuntime } from "../goals/runtime";
|
|
281
282
|
import type { Goal, GoalModeState } from "../goals/state";
|
|
282
283
|
import type { HindsightSessionState } from "../hindsight/state";
|
|
284
|
+
import { buildSecuritySkillActivationContext } from "../hooks/security-skill-keywords";
|
|
283
285
|
import {
|
|
284
286
|
buildSkillStopOutput,
|
|
285
287
|
detectPrimarySkillKeyword,
|
|
@@ -8354,6 +8356,7 @@ export class AgentSession {
|
|
|
8354
8356
|
const eagerTodoPrelude =
|
|
8355
8357
|
!options?.synthetic && !hasPendingUserDirective ? this.#createEagerTodoPrelude(expandedText) : undefined;
|
|
8356
8358
|
const uiSkillPrelude = options?.synthetic ? undefined : this.#createUiSkillPrelude(expandedText);
|
|
8359
|
+
const securitySkillPrelude = options?.synthetic ? undefined : this.#createSecuritySkillPrelude(expandedText);
|
|
8357
8360
|
const languagePrelude = options?.synthetic
|
|
8358
8361
|
? undefined
|
|
8359
8362
|
: this.#createResponseLanguagePrelude(expandedText, claimsGenuineUserIntent);
|
|
@@ -8386,10 +8389,11 @@ export class AgentSession {
|
|
|
8386
8389
|
await this.#promptWithMessage(message, expandedText, {
|
|
8387
8390
|
...options,
|
|
8388
8391
|
prependMessages:
|
|
8389
|
-
eagerTodoPrelude || uiSkillPrelude || languagePrelude
|
|
8392
|
+
eagerTodoPrelude || uiSkillPrelude || securitySkillPrelude || languagePrelude
|
|
8390
8393
|
? [
|
|
8391
8394
|
...(languagePrelude ? [languagePrelude] : []),
|
|
8392
8395
|
...(uiSkillPrelude ? [uiSkillPrelude] : []),
|
|
8396
|
+
...(securitySkillPrelude ? [securitySkillPrelude] : []),
|
|
8393
8397
|
...(eagerTodoPrelude ? [eagerTodoPrelude.message] : []),
|
|
8394
8398
|
]
|
|
8395
8399
|
: undefined,
|
|
@@ -12281,16 +12285,17 @@ export class AgentSession {
|
|
|
12281
12285
|
// Cache-epoch invariant: pruning rewrites already-sent toolResult history,
|
|
12282
12286
|
// which breaks the provider prompt-cache prefix mid-epoch. Only prune at a
|
|
12283
12287
|
// sanctioned maintenance boundary, i.e. when the un-pruned context already
|
|
12284
|
-
// crosses the compaction threshold
|
|
12288
|
+
// crosses the compaction threshold, and only when it frees enough headroom
|
|
12289
|
+
// to be worth the cache rewrite (shouldPruneAtThreshold). Otherwise compact.
|
|
12285
12290
|
if (!shouldCompact(contextTokens, contextWindow, compactionSettings, autoCompactionOutputReserveTokens))
|
|
12286
12291
|
return true;
|
|
12287
12292
|
const pruneEstimate = estimateToolOutputPruneSavings(this.sessionManager.getBranch(), DEFAULT_PRUNE_CONFIG, {
|
|
12288
12293
|
relaxedMinimum: 0,
|
|
12289
12294
|
});
|
|
12290
12295
|
if (
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12296
|
+
shouldPruneAtThreshold(
|
|
12297
|
+
contextTokens,
|
|
12298
|
+
pruneEstimate.tokensSaved,
|
|
12294
12299
|
contextWindow,
|
|
12295
12300
|
compactionSettings,
|
|
12296
12301
|
autoCompactionOutputReserveTokens,
|
|
@@ -12396,17 +12401,18 @@ export class AgentSession {
|
|
|
12396
12401
|
await this.sessionManager.flush();
|
|
12397
12402
|
if (isAborted()) return "aborted";
|
|
12398
12403
|
|
|
12399
|
-
// 1) Prune stale tool outputs
|
|
12400
|
-
//
|
|
12401
|
-
// prompt-cache epoch
|
|
12404
|
+
// 1) Prune stale tool outputs when that frees enough headroom to avert
|
|
12405
|
+
// compaction for a while (shouldPruneAtThreshold). Like all history
|
|
12406
|
+
// rewrites it resets the codex provider session / prompt-cache epoch
|
|
12407
|
+
// via #closeCodexProviderSessionsForHistoryRewrite.
|
|
12402
12408
|
const pruneEstimate = estimateToolOutputPruneSavings(this.sessionManager.getBranch(), DEFAULT_PRUNE_CONFIG, {
|
|
12403
12409
|
relaxedMinimum: 0,
|
|
12404
12410
|
});
|
|
12405
12411
|
let pruneResult: { prunedCount: number; tokensSaved: number } | undefined;
|
|
12406
12412
|
if (
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12413
|
+
shouldPruneAtThreshold(
|
|
12414
|
+
contextTokens,
|
|
12415
|
+
pruneEstimate.tokensSaved,
|
|
12410
12416
|
contextWindow,
|
|
12411
12417
|
runSettings,
|
|
12412
12418
|
autoCompactionOutputReserveTokens,
|
|
@@ -12607,9 +12613,9 @@ export class AgentSession {
|
|
|
12607
12613
|
relaxedMinimum: 0,
|
|
12608
12614
|
});
|
|
12609
12615
|
if (
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12616
|
+
shouldPruneAtThreshold(
|
|
12617
|
+
contextTokens,
|
|
12618
|
+
pruneEstimate.tokensSaved,
|
|
12613
12619
|
contextWindow,
|
|
12614
12620
|
compactionSettings,
|
|
12615
12621
|
autoCompactionOutputReserveTokens,
|
|
@@ -12795,6 +12801,20 @@ export class AgentSession {
|
|
|
12795
12801
|
};
|
|
12796
12802
|
}
|
|
12797
12803
|
|
|
12804
|
+
/** Same reminder shape as the UI skills, for the bundled security review skill. */
|
|
12805
|
+
#createSecuritySkillPrelude(promptText: string): AgentMessage | undefined {
|
|
12806
|
+
if (this.#planModeState?.enabled) return undefined;
|
|
12807
|
+
const directive = buildSecuritySkillActivationContext(promptText);
|
|
12808
|
+
if (!directive) return undefined;
|
|
12809
|
+
logger.debug("agent-session: bundled security skill matched", { promptChars: promptText.length });
|
|
12810
|
+
return {
|
|
12811
|
+
role: "developer",
|
|
12812
|
+
content: [{ type: "text", text: `<system-reminder>\n${directive}\n</system-reminder>` }],
|
|
12813
|
+
attribution: "agent",
|
|
12814
|
+
timestamp: Date.now(),
|
|
12815
|
+
};
|
|
12816
|
+
}
|
|
12817
|
+
|
|
12798
12818
|
#createEagerTodoPrelude(promptText: string): { message: AgentMessage; toolChoice?: ToolChoice } | undefined {
|
|
12799
12819
|
const eagerTodosEnabled = this.settings.get("todo.eager");
|
|
12800
12820
|
const todosEnabled = this.settings.get("todo.enabled");
|
package/src/utils/mupdf-wasm.ts
CHANGED
|
@@ -18,17 +18,25 @@
|
|
|
18
18
|
* resolves in a workspace checkout but breaks every published install
|
|
19
19
|
* (`bun install -g` / npm) where `@sayknow-cli/coding-agent` sits several
|
|
20
20
|
* directories deeper and mupdf is hoisted elsewhere — that was the 0.5.8
|
|
21
|
-
* startup crash.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* startup crash.
|
|
22
|
+
*
|
|
23
|
+
* MuPDF's JavaScript loader only runs the wasm built for the same release, so
|
|
24
|
+
* the hook is seeded in compiled binaries only. Anywhere else `mupdf` finds the
|
|
25
|
+
* wasm next to its own loader, which always matches, whatever version the
|
|
26
|
+
* installer resolved for markit-ai's `^1.27.0` range. A binary pairs these
|
|
27
|
+
* vendored bytes with the loader the lockfile resolves, so the root
|
|
28
|
+
* `overrides.mupdf` pin and the bytes
|
|
29
|
+
* (`node_modules/mupdf/dist/mupdf-wasm.wasm`) move together.
|
|
24
30
|
*
|
|
25
31
|
* This must run before the first `import("mupdf")` anywhere in the process.
|
|
26
32
|
*/
|
|
33
|
+
import { isCompiledBinary } from "@sayknow-cli/utils/env";
|
|
27
34
|
import mupdfWasmPath from "../../vendor/mupdf/mupdf-wasm.wasm" with { type: "file" };
|
|
28
35
|
|
|
29
36
|
const MODULE_CONFIG_KEY = "$libmupdf_wasm_Module";
|
|
30
37
|
|
|
31
|
-
export function ensureMupdfWasmResolution(): void {
|
|
38
|
+
export function ensureMupdfWasmResolution(compiled: boolean = isCompiledBinary()): void {
|
|
39
|
+
if (!compiled) return;
|
|
32
40
|
const globalScope = globalThis as typeof globalThis & Record<string, unknown>;
|
|
33
41
|
if (globalScope[MODULE_CONFIG_KEY] !== undefined) return;
|
|
34
42
|
globalScope[MODULE_CONFIG_KEY] = { locateFile: () => String(mupdfWasmPath) };
|