@krisada-m/ksd-intelligence 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +167 -2
- package/dist/adapters/agy/skills.js +252 -0
- package/dist/adapters/cli/check-changed.js +3 -0
- package/dist/adapters/cli/main.js +1002 -0
- package/dist/adapters/cli/policy-bin.js +10 -0
- package/dist/adapters/cli/review-verdict.js +3 -0
- package/dist/adapters/omp/extension.js +893 -0
- package/dist/adapters/omp/skills.js +130 -0
- package/dist/adapters/ui/hud.js +318 -0
- package/dist/adapters/ui/tree.js +460 -0
- package/dist/core/audit/index.js +2 -0
- package/dist/core/audit/log.js +505 -0
- package/dist/core/audit/summary.js +188 -0
- package/dist/core/changes/changes.js +591 -0
- package/dist/core/changes/git.js +266 -0
- package/dist/core/changes/plan.js +109 -0
- package/dist/core/changes/render.js +356 -0
- package/dist/core/engine/build.js +178 -0
- package/dist/core/engine/child.js +389 -0
- package/dist/core/engine/host.js +206 -0
- package/dist/core/engine/lock.js +133 -0
- package/dist/core/engine/protocol.js +43 -0
- package/dist/core/engine/runtime.js +44 -0
- package/dist/core/engine/status.js +381 -0
- package/dist/core/engine/typescript.js +194 -0
- package/dist/core/engine/workspace.js +72 -0
- package/dist/core/graph/graph.js +127 -0
- package/dist/core/graph/limits.js +16 -0
- package/dist/core/impact/query.js +1292 -0
- package/dist/core/impact/render.js +590 -0
- package/dist/core/impact/session.js +694 -0
- package/dist/core/indexing/declarations.js +455 -0
- package/dist/core/indexing/differential.js +345 -0
- package/dist/core/indexing/doctor.js +120 -0
- package/dist/core/indexing/indexer.js +792 -0
- package/dist/core/indexing/keys.js +451 -0
- package/dist/core/indexing/lexical.js +212 -0
- package/dist/core/indexing/packages.js +57 -0
- package/dist/core/indexing/program.js +171 -0
- package/dist/core/indexing/resolve.js +1004 -0
- package/dist/core/indexing/stamp.js +52 -0
- package/dist/core/indexing/surface.js +335 -0
- package/dist/core/indexing/ui-progress.js +37 -0
- package/dist/core/indexing/verify.js +76 -0
- package/dist/core/kernel/config.js +383 -0
- package/dist/core/kernel/glob.js +105 -0
- package/dist/core/kernel/guards.js +4 -0
- package/dist/core/kernel/types.js +3 -0
- package/dist/core/kernel/verdict.js +142 -0
- package/dist/core/knowledge/anchors.js +139 -0
- package/dist/core/knowledge/knowledge.js +95 -0
- package/dist/core/knowledge/learning.js +102 -0
- package/dist/core/knowledge/render.js +76 -0
- package/dist/core/knowledge/store.js +109 -0
- package/dist/core/knowledge/yaml.js +87 -0
- package/dist/core/search/lexical.js +382 -0
- package/dist/core/search/render.js +98 -0
- package/dist/core/search/segments.js +118 -0
- package/dist/core/verify/parse.js +127 -0
- package/dist/core/verify/render.js +67 -0
- package/dist/core/verify/report.js +40 -0
- package/dist/core/verify/revision.js +79 -0
- package/dist/core/verify/run.js +117 -0
- package/dist/core/verify/store.js +66 -0
- package/dist/core/verify/verify.js +173 -0
- package/dist/core/workspace/init.js +267 -0
- package/dist/core/workspace/probe.js +56 -0
- package/dist/core/workspace/scan.js +420 -0
- package/dist/index.js +20 -0
- package/dist/policy/change-scope.js +500 -0
- package/dist/policy/check-changed.js +40 -0
- package/dist/policy/config.js +106 -0
- package/dist/policy/dist/policy.d.ts +17 -0
- package/dist/policy/dist/policy.js +147 -0
- package/dist/policy/dist/runtime.d.ts +40 -0
- package/dist/policy/dist/runtime.js +75 -0
- package/dist/policy/dist/sdlc.d.ts +7 -0
- package/dist/policy/dist/sdlc.js +27 -0
- package/dist/policy/eslint-rules/index.js +107 -0
- package/dist/policy/index.d.ts +2 -0
- package/dist/policy/index.js +241 -0
- package/dist/policy/package.json +33 -0
- package/dist/policy/policy.d.ts +2 -0
- package/dist/policy/policy.js +2 -0
- package/dist/policy/review-verdict.js +262 -0
- package/dist/policy/sdlc.js +2 -0
- package/dist/storage/records.js +245 -0
- package/dist/storage/sqlite.js +314 -0
- package/dist/workflow/catalog.js +69 -0
- package/dist/workflow/classify.js +55 -0
- package/dist/workflow/loader.js +140 -0
- package/dist/workflow/packs.js +469 -0
- package/dist/workflow/registry.js +359 -0
- package/dist/workflow/render.js +61 -0
- package/dist/workflow/router.js +141 -0
- package/dist/workflow/sources.js +229 -0
- package/dist/workflow/types.js +44 -0
- package/dist/workflow/updates.js +532 -0
- package/package.json +74 -4
- package/scripts/agy-mcp.mjs +27 -0
- package/scripts/mcp/stdio.mjs +304 -0
- package/scripts/mcp/tools.mjs +451 -0
- package/skills/ksd-intelligence/SKILL.md +54 -0
- package/skills/matt-sdlc/SKILL.md +42 -0
- package/skills/osmani-quality/SKILL.md +38 -0
- package/skills/poteto-mode/SKILL.md +40 -0
- package/skills/pstack-analysis/SKILL.md +36 -0
- package/skills.lock.json +71 -0
- package/skills.registry.json +181 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { KSD_MODES } from "./sdlc.js";
|
|
2
|
+
// Keep this policy orthogonal to Ponytail's simplicity and over-engineering guidance.
|
|
3
|
+
export const SECTION_KEY = "engineering-proxy";
|
|
4
|
+
export const POLICY_MARKER = "[Engineering Proxy Policy]";
|
|
5
|
+
export const POLICY_END = "[End Engineering Proxy Policy]";
|
|
6
|
+
/** A complete line consisting only of a policy marker: the stable marker or a numbered legacy version. */
|
|
7
|
+
const COMPLETE_MARKER_LINE = /^\[Engineering Proxy Policy(?: v\d+(?:\.\d+)*)?\]\r?$/;
|
|
8
|
+
/** An array element is owned when it BEGINS with the stable or a numbered legacy marker (existing array contract). */
|
|
9
|
+
const LEADING_MARKER = /^\[Engineering Proxy Policy(?: v\d+(?:\.\d+)*)?\]/;
|
|
10
|
+
const changed = (next, base) => next !== base;
|
|
11
|
+
/**
|
|
12
|
+
* Locate complete owned blocks in a string prompt: each runs from a dedicated marker line to the next
|
|
13
|
+
* end-marker line. A marker line that is never closed, or one that is met again before its end, leaves the
|
|
14
|
+
* block unterminated and the whole correction denied (never guess its end or drop unrelated content).
|
|
15
|
+
*/
|
|
16
|
+
function findStringBlocks(base) {
|
|
17
|
+
const lines = [];
|
|
18
|
+
let position = 0;
|
|
19
|
+
while (position < base.length) {
|
|
20
|
+
const newlineAt = base.indexOf("\n", position);
|
|
21
|
+
const end = newlineAt === -1 ? base.length : newlineAt + 1;
|
|
22
|
+
lines.push({ text: base.slice(position, newlineAt === -1 ? base.length : newlineAt), start: position, end });
|
|
23
|
+
if (newlineAt === -1)
|
|
24
|
+
break;
|
|
25
|
+
position = end;
|
|
26
|
+
}
|
|
27
|
+
const blocks = [];
|
|
28
|
+
let unterminated = false;
|
|
29
|
+
let index = 0;
|
|
30
|
+
while (index < lines.length) {
|
|
31
|
+
const line = lines[index];
|
|
32
|
+
if (!COMPLETE_MARKER_LINE.test(line.text)) {
|
|
33
|
+
index += 1;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
let blockEnd = -1;
|
|
37
|
+
for (let probe = index + 1; probe < lines.length; probe++) {
|
|
38
|
+
const candidate = lines[probe];
|
|
39
|
+
if (candidate.text.replace(/\r$/, "") === POLICY_END) {
|
|
40
|
+
blockEnd = candidate.start + POLICY_END.length;
|
|
41
|
+
index = probe + 1;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
if (COMPLETE_MARKER_LINE.test(candidate.text)) {
|
|
45
|
+
unterminated = true;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (blockEnd < 0) {
|
|
50
|
+
unterminated = true;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
blocks.push({ start: line.start, end: blockEnd });
|
|
54
|
+
}
|
|
55
|
+
return { blocks, unterminated };
|
|
56
|
+
}
|
|
57
|
+
/** Remove every complete owned block, preserving unrelated bytes, and insert at most one policy where the first block stood. */
|
|
58
|
+
function reconcileString(base, policy, warn) {
|
|
59
|
+
const { blocks, unterminated } = findStringBlocks(base);
|
|
60
|
+
if (unterminated) {
|
|
61
|
+
warn?.("KSD could not replace/remove an unterminated legacy policy; restart the session.");
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
if (blocks.length === 0) {
|
|
65
|
+
if (policy === undefined)
|
|
66
|
+
return undefined; // Nothing owned to remove; keep the prompt as-is.
|
|
67
|
+
if (base === "")
|
|
68
|
+
return policy;
|
|
69
|
+
const next = `${base}\n\n${policy}`;
|
|
70
|
+
return changed(next, base) ? next : undefined;
|
|
71
|
+
}
|
|
72
|
+
const strippedParts = [];
|
|
73
|
+
let cursor = 0;
|
|
74
|
+
for (const block of blocks) {
|
|
75
|
+
strippedParts.push(base.slice(cursor, block.start));
|
|
76
|
+
cursor = block.end;
|
|
77
|
+
}
|
|
78
|
+
strippedParts.push(base.slice(cursor));
|
|
79
|
+
const stripped = strippedParts.join("");
|
|
80
|
+
const next = policy === undefined ? stripped : base.slice(0, blocks[0].start) + policy + stripped.slice(blocks[0].start);
|
|
81
|
+
return changed(next, base) ? next : undefined;
|
|
82
|
+
}
|
|
83
|
+
export function buildPolicy({ enforcement = "balanced" } = {}) {
|
|
84
|
+
if (!KSD_MODES.includes(enforcement))
|
|
85
|
+
throw new Error("Unsupported KSD enforcement mode");
|
|
86
|
+
const cleanCode = enforcement === "adaptive"
|
|
87
|
+
? "Adaptive Clean Code: flat by default. Guard clauses and early returns; no else after return; no nested if when a guard clause or a combined condition works. Mark avoidable nesting in changed code as FIX REQUIRED in reviews; keep behavior-sensitive cases as WARN. Never weaken security, transactions or error handling to flatten code."
|
|
88
|
+
: "Balanced Clean Code: prefer guard clauses and early returns where behavior is preserved; nesting findings stay advisory.";
|
|
89
|
+
return `${POLICY_MARKER}
|
|
90
|
+
KSD personal code style. Explicit user requirements and existing repo conventions win over it.
|
|
91
|
+
${cleanCode}
|
|
92
|
+
- No nested ternaries: use if, a small named function, or a lookup map.
|
|
93
|
+
- Blank line before a return only when two or more statements precede it in the same block; never before a first-statement return. One blank line between adjacent function implementations; leave TypeScript overload groups untouched.
|
|
94
|
+
- Errors: domain logic returns a typed result (discriminated union); IO and infrastructure throw and are caught at the boundary (route handler, job runner, UI error boundary).
|
|
95
|
+
- Types: no any, no \`as\` casts (\`as const\` is fine), no non-null \`!\`; narrow with type guards; exported functions declare return types.
|
|
96
|
+
- Extract a helper only when it is reused or its name makes the caller clearer; length alone is not a reason.
|
|
97
|
+
- Comments: one line explaining why; never restate the code.
|
|
98
|
+
- Preserve existing architecture, contracts, validation and accessibility; no unrelated renames or refactors.
|
|
99
|
+
- Ponytail owns YAGNI/simplification and /ponytail-review; do not duplicate or invoke it.
|
|
100
|
+
- Risky behavior (auth/authorization, payments, DB schema/queries/RLS, destructive data operations, secrets, concurrency): prove normal-user denial (cross-tenant, another owner's record, unauthenticated), keep idempotency and replay protection, check constraints, locks, transaction boundaries and migration compatibility. Never run real payments or destructive shared-database checks.
|
|
101
|
+
- Never claim a check passed without running it.
|
|
102
|
+
Enforcement=${enforcement}: repo gates stay authoritative; these rules are deterministic only where the repo enables the KSD ESLint profile. The full SDLC checklist is delivered by /engineering-review.
|
|
103
|
+
${POLICY_END}`;
|
|
104
|
+
}
|
|
105
|
+
/** Reconcile a string or array fallback prompt: remove owned guidance, or replace it with exactly one policy. */
|
|
106
|
+
function reconcileFallback(base, policy, warn) {
|
|
107
|
+
if (typeof base === "string") {
|
|
108
|
+
const next = reconcileString(base, policy, warn);
|
|
109
|
+
return next === undefined ? undefined : { systemPrompt: next };
|
|
110
|
+
}
|
|
111
|
+
const owned = base
|
|
112
|
+
.map((part, index) => (typeof part === "string" && LEADING_MARKER.test(part) ? index : -1))
|
|
113
|
+
.filter(index => index >= 0);
|
|
114
|
+
if (owned.length === 0) {
|
|
115
|
+
return policy === undefined ? undefined : { systemPrompt: [...base, policy] };
|
|
116
|
+
}
|
|
117
|
+
if (owned.length === 1 && base[owned[0]] === policy)
|
|
118
|
+
return undefined;
|
|
119
|
+
if (policy === undefined) {
|
|
120
|
+
return { systemPrompt: base.filter((_part, index) => !owned.includes(index)) };
|
|
121
|
+
}
|
|
122
|
+
// Exactly one owned element survives: unrelated order preserved, extra owned elements dropped.
|
|
123
|
+
return { systemPrompt: base.flatMap((part, index) => {
|
|
124
|
+
if (owned.includes(index))
|
|
125
|
+
return index === owned[0] ? [policy] : [];
|
|
126
|
+
return [part];
|
|
127
|
+
}) };
|
|
128
|
+
}
|
|
129
|
+
export function augmentSystemPrompt(event, policy, warn) {
|
|
130
|
+
const sections = event?.systemPromptOptions?.sections;
|
|
131
|
+
// Do not add a structured policy if an unterminated fallback cannot be removed.
|
|
132
|
+
if (sections && typeof sections === "object") {
|
|
133
|
+
let failed = false;
|
|
134
|
+
const fallback = event?.systemPrompt === undefined ? undefined : reconcileFallback(event.systemPrompt, undefined, message => {
|
|
135
|
+
failed = true;
|
|
136
|
+
warn?.(message);
|
|
137
|
+
});
|
|
138
|
+
if (policy === undefined || failed)
|
|
139
|
+
delete sections[SECTION_KEY];
|
|
140
|
+
else
|
|
141
|
+
sections[SECTION_KEY] = policy;
|
|
142
|
+
return fallback;
|
|
143
|
+
}
|
|
144
|
+
return event?.systemPrompt === undefined
|
|
145
|
+
? (policy === undefined ? undefined : { systemPrompt: policy })
|
|
146
|
+
: reconcileFallback(event.systemPrompt, policy, warn);
|
|
147
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** In-process hot-path engine. No native processes, filesystem access or LLM calls. */
|
|
2
|
+
import type { KsdMode } from "./sdlc.js";
|
|
3
|
+
export interface KsdConfig {
|
|
4
|
+
readonly enabled: boolean;
|
|
5
|
+
readonly enforcement: "balanced" | "adaptive";
|
|
6
|
+
readonly configError?: string;
|
|
7
|
+
readonly root?: string;
|
|
8
|
+
readonly configPresent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface KsdTheme {
|
|
11
|
+
fg?(style: string, text: string): string;
|
|
12
|
+
}
|
|
13
|
+
export interface KsdUi {
|
|
14
|
+
setStatus?(key: string, value: string | undefined): void;
|
|
15
|
+
readonly theme?: KsdTheme;
|
|
16
|
+
}
|
|
17
|
+
export interface KsdContext {
|
|
18
|
+
readonly cwd?: string;
|
|
19
|
+
readonly ui?: KsdUi;
|
|
20
|
+
}
|
|
21
|
+
type LoadConfig = (cwd: string) => KsdConfig;
|
|
22
|
+
type BuildPolicy = (config: {
|
|
23
|
+
enforcement: KsdMode;
|
|
24
|
+
}) => string;
|
|
25
|
+
type IsDisabled = () => boolean;
|
|
26
|
+
export declare class KsdRuntime {
|
|
27
|
+
private readonly loadConfig;
|
|
28
|
+
private readonly buildPolicy;
|
|
29
|
+
private readonly isDisabled;
|
|
30
|
+
private readonly configs;
|
|
31
|
+
private readonly policies;
|
|
32
|
+
private readonly statuses;
|
|
33
|
+
constructor(loadConfig: LoadConfig, buildPolicy: BuildPolicy, isDisabled: IsDisabled);
|
|
34
|
+
getConfig(cwd: string, refresh?: boolean): KsdConfig;
|
|
35
|
+
getPolicy(mode: KsdMode): string;
|
|
36
|
+
/** Redraw after session/UI resets even if status text is unchanged. */
|
|
37
|
+
invalidateStatus(ui?: KsdUi): void;
|
|
38
|
+
syncStatus(ctx: KsdContext | undefined, isActive: boolean, mode: KsdConfig["enforcement"], notice?: string): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export class KsdRuntime {
|
|
2
|
+
loadConfig;
|
|
3
|
+
buildPolicy;
|
|
4
|
+
isDisabled;
|
|
5
|
+
configs = new Map();
|
|
6
|
+
policies = new Map();
|
|
7
|
+
statuses = new WeakMap();
|
|
8
|
+
constructor(loadConfig, buildPolicy, isDisabled) {
|
|
9
|
+
this.loadConfig = loadConfig;
|
|
10
|
+
this.buildPolicy = buildPolicy;
|
|
11
|
+
this.isDisabled = isDisabled;
|
|
12
|
+
}
|
|
13
|
+
getConfig(cwd, refresh = false) {
|
|
14
|
+
const known = this.configs.get(cwd);
|
|
15
|
+
if (!refresh && known)
|
|
16
|
+
return known;
|
|
17
|
+
const next = this.loadConfig(cwd);
|
|
18
|
+
this.configs.set(cwd, next);
|
|
19
|
+
return next;
|
|
20
|
+
}
|
|
21
|
+
getPolicy(mode) {
|
|
22
|
+
const existing = this.policies.get(mode);
|
|
23
|
+
if (existing !== undefined)
|
|
24
|
+
return existing;
|
|
25
|
+
// The single-field config object is allocated only on a two-mode cache miss.
|
|
26
|
+
const policy = this.buildPolicy({ enforcement: mode });
|
|
27
|
+
this.policies.set(mode, policy);
|
|
28
|
+
return policy;
|
|
29
|
+
}
|
|
30
|
+
/** Redraw after session/UI resets even if status text is unchanged. */
|
|
31
|
+
invalidateStatus(ui) {
|
|
32
|
+
if (ui)
|
|
33
|
+
this.statuses.delete(ui);
|
|
34
|
+
}
|
|
35
|
+
syncStatus(ctx, isActive, mode, notice) {
|
|
36
|
+
const ui = ctx?.ui;
|
|
37
|
+
if (typeof ui?.setStatus !== "function" || !ctx?.cwd)
|
|
38
|
+
return;
|
|
39
|
+
try {
|
|
40
|
+
const config = this.getConfig(ctx.cwd);
|
|
41
|
+
const enabled = config.enabled && !this.isDisabled();
|
|
42
|
+
let theme;
|
|
43
|
+
try {
|
|
44
|
+
theme = ui.theme;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Missing theme must never break headless/early-start UIs.
|
|
48
|
+
}
|
|
49
|
+
const paint = (tone, text) => {
|
|
50
|
+
try {
|
|
51
|
+
return typeof theme?.fg === "function" ? theme.fg(tone, text) : text;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return text;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
let status;
|
|
58
|
+
if (enabled) {
|
|
59
|
+
status = `${paint(isActive ? "accent" : "dim", isActive ? "●" : "○")} 🛡 ${paint("dim", "KSD:")} ${paint(isActive ? "accent" : "dim", mode.toUpperCase())}`;
|
|
60
|
+
if (notice)
|
|
61
|
+
status += `; ${notice}`;
|
|
62
|
+
}
|
|
63
|
+
else if (notice)
|
|
64
|
+
status = `${paint("accent", "⚠")} ${paint("dim", "KSD:")} ${notice}`;
|
|
65
|
+
const before = this.statuses.get(ui);
|
|
66
|
+
if (before && before.value === status && before.theme === theme)
|
|
67
|
+
return;
|
|
68
|
+
ui.setStatus("engineering-proxy", status);
|
|
69
|
+
this.statuses.set(ui, { value: status, theme, notice });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Decorative UI must never cause a coding session to fail.
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Lightweight SDLC guidance; not an automatic release gate. */
|
|
2
|
+
export declare const KSD_MODES: readonly ["balanced", "adaptive"];
|
|
3
|
+
export type KsdMode = (typeof KSD_MODES)[number];
|
|
4
|
+
export declare const SDLC_PHASES: readonly string[];
|
|
5
|
+
export declare function buildSdlcPolicy({ mode }?: {
|
|
6
|
+
mode?: KsdMode;
|
|
7
|
+
}): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Lightweight SDLC guidance; not an automatic release gate. */
|
|
2
|
+
export const KSD_MODES = Object.freeze(["balanced", "adaptive"]);
|
|
3
|
+
export const SDLC_PHASES = Object.freeze([
|
|
4
|
+
"Requirements",
|
|
5
|
+
"Design",
|
|
6
|
+
"Implementation",
|
|
7
|
+
"Verification",
|
|
8
|
+
"Delivery",
|
|
9
|
+
]);
|
|
10
|
+
const REVIEW_GUIDANCE = "Review ownership/authorization by testing normal-user denial (cross-tenant, another owner's record, unauthenticated); a service-role or admin success alone never proves isolation. Where payments are affected, preserve confirmation, idempotency and replay protection and never execute real provider transactions. Where databases are affected, check constraints, locks and transaction boundaries, and migration compatibility with existing data; review deletion scope, cascades and recovery paths. Never invent TTL, provider, or retention semantics, and never run real payment or destructive shared-database checks.";
|
|
11
|
+
export function buildSdlcPolicy({ mode = "balanced" } = {}) {
|
|
12
|
+
if (!KSD_MODES.includes(mode))
|
|
13
|
+
throw new Error("Invalid SDLC policy mode");
|
|
14
|
+
return [
|
|
15
|
+
"SDLC workflow (proportional to the actual change; never fabricate evidence or create unnecessary documents):",
|
|
16
|
+
"1. Requirements: identify intent, acceptance criteria, affected users/contracts and unknowns before changing behavior. State a short acceptance note for UI/cosmetic work and focused checks instead of document ceremony.",
|
|
17
|
+
"2. Design: inspect existing callers, architecture, data flow and invariants. Compare only relevant alternatives; avoid speculative abstraction or redesign.",
|
|
18
|
+
"3. Implementation: smallest behavior-preserving change, guard clauses where clearer, no unrelated churn. Apply repo conventions and Ponytail simplification without duplicating it.",
|
|
19
|
+
"4. Verification: select tests by impact; verify negative/error cases, contracts, types and security when relevant. Distinguish skipped, missing, and actually executed gates.",
|
|
20
|
+
"5. Delivery: summarize changed files, test commands/results, remaining risks, rollback impact and explicit approval blockers. Never automatically push, merge or deploy.",
|
|
21
|
+
"Escalate on behavior in either mode, not filenames: Auth, Payments, Database/schema/query changes, row-level security/authorization, destructive data operations, secrets and concurrency require stronger design and security evidence. " + REVIEW_GUIDANCE,
|
|
22
|
+
"When a requirement is unclear, ask or mark it UNKNOWN instead of inventing policy, TTL, database state or provider behavior.",
|
|
23
|
+
mode === "adaptive"
|
|
24
|
+
? "Adaptive emphasis: use the lightest sufficient SDLC evidence for each change, but escalate on risky contracts or behavior. Keep control flow flat where semantics allow."
|
|
25
|
+
: "Balanced emphasis: preserve the repository's established checkpoints, with explicit evidence for all applicable gates.",
|
|
26
|
+
].join("\n");
|
|
27
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Optional ESLint flat-config rules. ESLint supplies the AST, so OMP needs no parser dependency.
|
|
2
|
+
// Enable in each repository deliberately; this module is not auto-run by the OMP extension.
|
|
3
|
+
|
|
4
|
+
// A return after a single statement may hug it (`const x = f();` then `return x;`); from two statements on it needs air.
|
|
5
|
+
const MIN_PRECEDING_FOR_BLANK = 2;
|
|
6
|
+
|
|
7
|
+
function getTextAndGap(context, previous, next) {
|
|
8
|
+
const source = context.sourceCode ?? context.getSourceCode();
|
|
9
|
+
const begin = previous.loc.end.line;
|
|
10
|
+
const end = next.loc.start.line;
|
|
11
|
+
const between = source.lines.slice(begin, Math.max(begin, end - 1));
|
|
12
|
+
const blankCount = between.filter(line => line.trim() === "").length;
|
|
13
|
+
const containsOtherContent = between.some(line => line.trim() !== "");
|
|
14
|
+
|
|
15
|
+
return { blankCount, containsOtherContent };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function adjacentImplementations(body) {
|
|
19
|
+
return Array.isArray(body) ? body.filter(Boolean) : [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isFunction(node) {
|
|
23
|
+
if (node?.type === "ExportNamedDeclaration" || node?.type === "ExportDefaultDeclaration") {
|
|
24
|
+
return isFunction(node.declaration);
|
|
25
|
+
}
|
|
26
|
+
if (node?.type === "FunctionDeclaration") return Boolean(node.body); // excludes TS overload signatures
|
|
27
|
+
if (node?.type !== "VariableDeclaration") return false;
|
|
28
|
+
|
|
29
|
+
return node.declarations?.length === 1 &&
|
|
30
|
+
["ArrowFunctionExpression", "FunctionExpression"].includes(node.declarations[0]?.init?.type);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const rules = {
|
|
34
|
+
"blank-before-return": {
|
|
35
|
+
meta: {
|
|
36
|
+
type: "layout",
|
|
37
|
+
docs: { description: "One empty line before a return preceded by two or more statements; never more than one" },
|
|
38
|
+
schema: [],
|
|
39
|
+
messages: { missing: "Leave exactly one blank line before this return.", extra: "Leave only one blank line before this return." },
|
|
40
|
+
},
|
|
41
|
+
create(context) {
|
|
42
|
+
return {
|
|
43
|
+
ReturnStatement(node) {
|
|
44
|
+
const siblings = node.parent?.body;
|
|
45
|
+
if (!Array.isArray(siblings)) return;
|
|
46
|
+
const index = siblings.indexOf(node);
|
|
47
|
+
if (index <= 0) return;
|
|
48
|
+
const { blankCount, containsOtherContent } = getTextAndGap(context, siblings[index - 1], node);
|
|
49
|
+
if (containsOtherContent) return; // comments/preprocessor matter; avoid false positives
|
|
50
|
+
if (blankCount > 1) {
|
|
51
|
+
context.report({ node, messageId: "extra" });
|
|
52
|
+
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (blankCount === 0 && index >= MIN_PRECEDING_FOR_BLANK) context.report({ node, messageId: "missing" });
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
"blank-between-functions": {
|
|
61
|
+
meta: {
|
|
62
|
+
type: "layout",
|
|
63
|
+
docs: { description: "Exactly one blank line between adjacent function implementations" },
|
|
64
|
+
schema: [],
|
|
65
|
+
messages: { missing: "Leave exactly one blank line between function implementations.", extra: "Leave only one blank line between function implementations." },
|
|
66
|
+
},
|
|
67
|
+
create(context) {
|
|
68
|
+
function inspect(body) {
|
|
69
|
+
const statements = adjacentImplementations(body);
|
|
70
|
+
for (let i = 1; i < statements.length; i++) {
|
|
71
|
+
const before = statements[i - 1];
|
|
72
|
+
const after = statements[i];
|
|
73
|
+
if (!isFunction(before) || !isFunction(after)) continue;
|
|
74
|
+
const { blankCount, containsOtherContent } = getTextAndGap(context, before, after);
|
|
75
|
+
if (containsOtherContent) continue;
|
|
76
|
+
if (blankCount !== 1) context.report({ node: after, messageId: blankCount === 0 ? "missing" : "extra" });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
Program(node) { inspect(node.body); },
|
|
82
|
+
BlockStatement(node) { inspect(node.body); },
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
"prefer-guard-clauses": {
|
|
87
|
+
meta: {
|
|
88
|
+
type: "suggestion",
|
|
89
|
+
docs: { description: "Warn on avoidable directly nested if blocks; no unsafe auto-fix" },
|
|
90
|
+
schema: [],
|
|
91
|
+
messages: { nested: "Consider a guard clause instead of a nested if, if behavior remains equivalent." },
|
|
92
|
+
},
|
|
93
|
+
create(context) {
|
|
94
|
+
return {
|
|
95
|
+
IfStatement(node) {
|
|
96
|
+
if (node.alternate) return;
|
|
97
|
+
const only = node.consequent?.type === "BlockStatement" ? node.consequent.body : [];
|
|
98
|
+
if (only.length === 1 && only[0]?.type === "IfStatement") {
|
|
99
|
+
context.report({ node: only[0], messageId: "nested" });
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default { rules };
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { loadConfig, setScopedMode, SUPPORTED_MODES } from "./config.js";
|
|
2
|
+
import { buildSdlcPolicy } from "./sdlc.js";
|
|
3
|
+
import { augmentSystemPrompt, buildPolicy, SECTION_KEY } from "./policy.js";
|
|
4
|
+
import { KsdRuntime } from "./dist/runtime.js";
|
|
5
|
+
|
|
6
|
+
const MODE_ENTRY = "engineering-proxy-mode";
|
|
7
|
+
const isDisabledByEnv = () => process.env.ENGINEERING_PROXY_DISABLED === "1";
|
|
8
|
+
|
|
9
|
+
export function parseEngineeringCommand(input) {
|
|
10
|
+
const words = String(input ?? "").trim().toLowerCase().split(/\s+/);
|
|
11
|
+
if (words.length === 1) {
|
|
12
|
+
if (words[0] === "" || words[0] === "status") return { type: "status" };
|
|
13
|
+
if (SUPPORTED_MODES.includes(words[0])) return { type: "set-mode", mode: words[0] };
|
|
14
|
+
if (words[0] === "reset") return { type: "reset-session" };
|
|
15
|
+
}
|
|
16
|
+
if (words.length === 2 && ["global", "repo"].includes(words[0])) {
|
|
17
|
+
if (SUPPORTED_MODES.includes(words[1])) return { type: "set-scoped-mode", scope: words[0], mode: words[1] };
|
|
18
|
+
if (words[1] === "reset") return { type: "reset-scoped-mode", scope: words[0] };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return { type: "invalid" };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function sessionOverride(entries) {
|
|
25
|
+
if (!Array.isArray(entries)) return null;
|
|
26
|
+
|
|
27
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
28
|
+
const entry = entries[i];
|
|
29
|
+
if (entry?.type !== "custom" || entry?.customType !== MODE_ENTRY) continue;
|
|
30
|
+
if (entry.data?.reset === true) return null;
|
|
31
|
+
if (SUPPORTED_MODES.includes(entry.data?.mode)) return entry.data.mode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function resolveSessionMode(entries, fallback = "balanced") {
|
|
38
|
+
const defaultMode = SUPPORTED_MODES.includes(fallback) ? fallback : "balanced";
|
|
39
|
+
|
|
40
|
+
return sessionOverride(entries) ?? defaultMode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const REVIEW_INSTRUCTIONS = `Review the current requested change as Engineering Proxy. This delegation does not run any review code for you: perform the inspection yourself through your permitted tools, following OMP permissions and approvals.
|
|
44
|
+
|
|
45
|
+
1. Requirements: state the acceptance criteria and what the change must not break. Check requirements, relevant callers and contracts.
|
|
46
|
+
2. Scope: inspect the actual diff of tracked changes against the operator's stated base (or HEAD for worktree review), plus intended untracked files (NUL-safe discovery, \`git diff --no-index --no-ext-diff --no-textconv -U0 -- /dev/null <path>\`; exit 1 means differences), deletions and renames. Never stage user files to manufacture scope. A path keyword is a hint, not proof that other files are low risk.
|
|
47
|
+
3. Checks: discover the repository's existing check commands first and inspect their safety; declare the applicable required and critical gates, then select typecheck/lint/tests/runtime/CI checks and execute only through permitted tools. Record exact cwd, exit code, output and pass/fail/skip counts. Missing or denied commands and credentials are NOT_RUN or BLOCKED. Never run migrations, database resets or real payments in shared environments.
|
|
48
|
+
4. Evidence: a skipped test without required environment is NOT_RUN, not PASS. A CI YAML file is not proof its job exercised the change; inspect actual relevant job and step execution for the reviewed commit and distinguish dirty/untracked behavior it cannot cover. Source-only inspection cannot verify an executed gate. Optional installed ksd-check-changed and ksd-review-verdict validators may be invoked through approved OMP tools with supplied reports and required gates; they do not run checks or authenticate evidence. A tiny review needs no report file: report the observed evidence directly.
|
|
49
|
+
5. Risk: escalate Auth, Payments, Database/schema/query changes, RLS/authorization, destructive data operations, secrets and concurrency based on behavior, not filenames. For auth check normal-user denial (cross-tenant, another owner's record, unauthenticated; service-role success is not isolation proof). For payments preserve confirmation, idempotency and replay protection. For databases check constraints, locks, transaction boundaries and migration compatibility. For deletions check scope, cascades and recovery.
|
|
50
|
+
6. Style: independently verify the KSD style profile from the Engineering Proxy policy (guard clauses, no nested ternaries, result-vs-throw error split, strict types, why-only comments, blank-line rules), repo conventions and type safety. Review changed scope, not unrelated code.
|
|
51
|
+
Report: acceptance criteria, affected contracts/risk, findings anchored to files with severity, exact observed check evidence (commands and results), and missing/denied/skipped/failed checks — then delivery and rollback implications. Never label release or merge readiness with unresolved required or security gates; no auto release/merge/push/deploy. Ponytail review must not be invoked here unless the user separately requested it; do not report a pass you did not observe.`;
|
|
52
|
+
|
|
53
|
+
export function createExtension(pi, { globalConfigPath } = {}) {
|
|
54
|
+
pi.setLabel?.("Engineering Proxy");
|
|
55
|
+
// One runtime per extension instance: caches must not leak between hosts or tests.
|
|
56
|
+
const runtime = new KsdRuntime(cwd => loadConfig(cwd, { globalConfigPath }), buildPolicy, isDisabledByEnv);
|
|
57
|
+
|
|
58
|
+
let isActive = false;
|
|
59
|
+
let selectedSessionMode = null;
|
|
60
|
+
let lastWarning = null;
|
|
61
|
+
const effectiveMode = config => selectedSessionMode ?? config.enforcement;
|
|
62
|
+
|
|
63
|
+
const refreshConfig = ctx => runtime.getConfig(ctx?.cwd ?? process.cwd(), true);
|
|
64
|
+
|
|
65
|
+
const updateStatus = (ctx, config, notice) => runtime.syncStatus(ctx, isActive, effectiveMode(config), notice);
|
|
66
|
+
|
|
67
|
+
function notifyWarningOnce(ctx, message) {
|
|
68
|
+
if (lastWarning === message) return;
|
|
69
|
+
lastWarning = message;
|
|
70
|
+
ctx?.ui?.notify?.(`${message} (${SECTION_KEY})`, "warning");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function clearWarning() {
|
|
74
|
+
lastWarning = null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reconcile the prompt in one call for both enabled and disabled paths.
|
|
79
|
+
* `undefined` policy removes owned guidance; a failed legacy reconciliation is stored and notified
|
|
80
|
+
* once per unchanged warning, never claimed as success.
|
|
81
|
+
*/
|
|
82
|
+
function reconcilePrompt(event, ctx, policy) {
|
|
83
|
+
let warned = false;
|
|
84
|
+
const result = augmentSystemPrompt(event, policy, message => {
|
|
85
|
+
warned = true;
|
|
86
|
+
notifyWarningOnce(ctx, message);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (warned) return { result, warned: true };
|
|
90
|
+
clearWarning();
|
|
91
|
+
|
|
92
|
+
return { result, warned: false };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function restoreSession(ctx) {
|
|
96
|
+
isActive = false;
|
|
97
|
+
const config = refreshConfig(ctx);
|
|
98
|
+
runtime.invalidateStatus(ctx?.ui);
|
|
99
|
+
const sessionManager = ctx?.sessionManager;
|
|
100
|
+
|
|
101
|
+
// getBranch() is authoritative: nullish/malformed/throwing branch data means no session override,
|
|
102
|
+
// never a fallback to all-branches entries.
|
|
103
|
+
if (typeof sessionManager?.getBranch === "function") {
|
|
104
|
+
try {
|
|
105
|
+
selectedSessionMode = sessionOverride(sessionManager.getBranch());
|
|
106
|
+
} catch {
|
|
107
|
+
selectedSessionMode = null;
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
try {
|
|
111
|
+
selectedSessionMode = sessionOverride(sessionManager?.getEntries?.() ?? []);
|
|
112
|
+
} catch {
|
|
113
|
+
selectedSessionMode = null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
updateStatus(ctx, config, lastWarning ?? undefined);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
for (const eventName of ["session_start", "session_tree", "session_switch", "session_branch"]) {
|
|
121
|
+
pi.on(eventName, (_event, ctx) => restoreSession(ctx));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
pi.on("agent_start", (_event, ctx) => {
|
|
125
|
+
isActive = true;
|
|
126
|
+
updateStatus(ctx, runtime.getConfig(ctx?.cwd ?? process.cwd()), lastWarning ?? undefined);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
pi.on("agent_end", (_event, ctx) => {
|
|
130
|
+
isActive = false;
|
|
131
|
+
updateStatus(ctx, runtime.getConfig(ctx?.cwd ?? process.cwd()), lastWarning ?? undefined);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
pi.on("before_agent_start", (event, ctx) => {
|
|
135
|
+
const config = refreshConfig(ctx);
|
|
136
|
+
const policy = !config.enabled || isDisabledByEnv() ? undefined : runtime.getPolicy(effectiveMode(config));
|
|
137
|
+
const { result } = reconcilePrompt(event, ctx, policy);
|
|
138
|
+
updateStatus(ctx, config, lastWarning ?? undefined);
|
|
139
|
+
|
|
140
|
+
return result;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
pi.registerCommand("engineering-proxy", {
|
|
144
|
+
description: "Engineering policy: status, session mode/reset, global mode/reset, repo mode/reset",
|
|
145
|
+
handler: async (args, ctx) => {
|
|
146
|
+
// Refresh and draw status BEFORE any validation or disabled early return, so a rejected
|
|
147
|
+
// command cannot leave stale status behind.
|
|
148
|
+
const config = refreshConfig(ctx);
|
|
149
|
+
updateStatus(ctx, config, lastWarning ?? undefined);
|
|
150
|
+
const parsed = parseEngineeringCommand(args);
|
|
151
|
+
const enabled = config.enabled && !isDisabledByEnv();
|
|
152
|
+
|
|
153
|
+
if (parsed.type === "invalid") {
|
|
154
|
+
ctx.ui?.notify?.("Usage: /engineering-proxy [status|balanced|adaptive|reset|global <balanced|adaptive|reset>|repo <balanced|adaptive|reset>]", "warning");
|
|
155
|
+
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (parsed.type === "set-mode" || parsed.type === "reset-session") {
|
|
160
|
+
if (!enabled && parsed.type === "set-mode") {
|
|
161
|
+
ctx.ui?.notify?.("Engineering Proxy is disabled; mode unchanged.", "warning");
|
|
162
|
+
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
selectedSessionMode = parsed.type === "reset-session" ? null : parsed.mode;
|
|
167
|
+
let persisted = false;
|
|
168
|
+
try {
|
|
169
|
+
if (typeof pi.appendEntry === "function") {
|
|
170
|
+
pi.appendEntry(MODE_ENTRY, parsed.type === "reset-session" ? { reset: true } : { mode: selectedSessionMode });
|
|
171
|
+
persisted = true;
|
|
172
|
+
}
|
|
173
|
+
} catch {
|
|
174
|
+
// Runtime policy still updates, but session mode cannot be replayed.
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
updateStatus(ctx, config, lastWarning ?? undefined);
|
|
178
|
+
const effective = effectiveMode(config);
|
|
179
|
+
ctx.ui?.notify?.(`KSD mode: ${effective.toUpperCase()} (${persisted ? "saved in session" : "runtime only; session persistence unavailable"})`, persisted ? "info" : "warning");
|
|
180
|
+
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (parsed.type === "set-scoped-mode" || parsed.type === "reset-scoped-mode") {
|
|
185
|
+
const mode = parsed.type === "reset-scoped-mode" ? null : parsed.mode;
|
|
186
|
+
try {
|
|
187
|
+
const path = setScopedMode(ctx.cwd, parsed.scope, mode, { globalConfigPath });
|
|
188
|
+
const next = refreshConfig(ctx);
|
|
189
|
+
updateStatus(ctx, next, lastWarning ?? undefined);
|
|
190
|
+
ctx.ui?.notify?.(`KSD ${parsed.scope} ${mode ?? "reset"} saved to ${path}; effective: ${effectiveMode(next).toUpperCase()} (${selectedSessionMode ? "session" : next.enforcementSource})`, "info");
|
|
191
|
+
} catch (error) {
|
|
192
|
+
ctx.ui?.notify?.(`KSD ${parsed.scope} update failed: ${error.message}`, "warning");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const names = pi.getCommands?.() ?? [];
|
|
199
|
+
const ponytailFound = Array.isArray(names) && names.some(command => command?.name === "ponytail");
|
|
200
|
+
const msg = `Engineering Proxy: ${enabled ? "ON" : "OFF"}; mode: ${effectiveMode(config).toUpperCase()} (${selectedSessionMode ? "session" : config.enforcementSource}); project default: ${(config.projectEnforcement ?? "unset").toUpperCase()}; global default: ${(config.globalEnforcement ?? "unset").toUpperCase()}; session: ${(selectedSessionMode ?? "inherit").toUpperCase()}; Ponytail command: ${ponytailFound ? "detected" : "not detected/unknown"}; Ponytail mode: not inspected`;
|
|
201
|
+
const warnings = [config.configError, lastWarning].filter(Boolean);
|
|
202
|
+
const plain = warnings.length ? `${msg}; WARNING: ${warnings.join("; ")}` : msg;
|
|
203
|
+
let display = plain;
|
|
204
|
+
try {
|
|
205
|
+
const theme = ctx.ui?.theme;
|
|
206
|
+
if (typeof theme?.fg === "function") {
|
|
207
|
+
display = plain.replace(/(Engineering Proxy: |; mode: |; project default: |; global default: |; session: )(ON|OFF|BALANCED|ADAPTIVE|UNSET|INHERIT)/g,
|
|
208
|
+
(_match, label, value) => `${label}${theme.fg("accent", value)}`)
|
|
209
|
+
.replace(/Engineering Proxy:|; mode:|; project default:|; global default:|; session:|; Ponytail command:|; Ponytail mode:|; WARNING:/g,
|
|
210
|
+
label => theme.fg(label === "; WARNING:" ? "accent" : "dim", label));
|
|
211
|
+
}
|
|
212
|
+
} catch {
|
|
213
|
+
display = plain;
|
|
214
|
+
}
|
|
215
|
+
ctx.ui?.notify?.(display, warnings.length ? "warning" : "info");
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
pi.registerCommand("engineering-review", {
|
|
220
|
+
description: "Request a scoped, evidence-based engineering review (Ponytail optional)",
|
|
221
|
+
handler: async (args, ctx) => {
|
|
222
|
+
const config = refreshConfig(ctx);
|
|
223
|
+
updateStatus(ctx, config, lastWarning ?? undefined);
|
|
224
|
+
if (!config.enabled || isDisabledByEnv()) {
|
|
225
|
+
ctx.ui?.notify?.("Engineering Proxy is disabled for this project", "warning");
|
|
226
|
+
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const scope = typeof args === "string" && args.trim() ? `\nReview scope: ${args.trim()}` : "";
|
|
230
|
+
const message = `${REVIEW_INSTRUCTIONS}\n\n${buildSdlcPolicy({ mode: effectiveMode(config) })}${scope}`;
|
|
231
|
+
// Explicit operator command only: no automatic Ponytail invocation.
|
|
232
|
+
if (ctx.isIdle?.() === false) {
|
|
233
|
+
pi.sendUserMessage(message, { deliverAs: "followUp" });
|
|
234
|
+
} else {
|
|
235
|
+
pi.sendUserMessage(message);
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export default createExtension;
|