@event4u/agent-config 9.16.0 → 9.18.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/.claude-plugin/marketplace.json +1 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +80 -130
- package/README.md +1 -1
- package/dist/agent-src/commands/agent-handoff.md +100 -48
- package/dist/agent-src/commands/challenge-me/vision.md +5 -0
- package/dist/agent-src/commands/commit.md +1 -1
- package/dist/agent-src/commands/condense.md +19 -64
- package/dist/agent-src/commands/evals/agent-handoff.json +13 -1
- package/dist/agent-src/commands/evals/rule-compliance-audit.json +46 -0
- package/dist/agent-src/commands/feature/plan.md +20 -0
- package/dist/agent-src/commands/feature/roadmap.md +19 -0
- package/dist/agent-src/commands/memory/promote.md +14 -1
- package/dist/agent-src/commands/mode.md +9 -5
- package/dist/agent-src/commands/optimize/deep.md +72 -11
- package/dist/agent-src/commands/pr/create.md +29 -0
- package/dist/agent-src/commands/roadmap/create.md +29 -0
- package/dist/agent-src/commands/rule-compliance-audit.md +28 -5
- package/dist/agent-src/contexts/authority/commit-mechanics.md +5 -5
- package/dist/agent-src/contexts/communication/rules-auto/guidelines-mechanics.md +1 -0
- package/dist/agent-src/contexts/communication/rules-auto/skill-quality-mechanics.md +1 -1
- package/dist/agent-src/contexts/communication/rules-auto/think-before-action-mechanics.md +6 -1
- package/dist/agent-src/contexts/communication/rules-auto/token-efficiency-mechanics.md +4 -1
- package/dist/agent-src/contexts/execution/autonomy-mechanics.md +27 -1
- package/dist/agent-src/contexts/execution/plan-confidence-gate.md +133 -0
- package/dist/agent-src/contexts/execution/roadmap-process-loop.md +5 -2
- package/dist/agent-src/profiles/agency.yml +3 -3
- package/dist/agent-src/profiles/content_creator.yml +2 -2
- package/dist/agent-src/profiles/developer.yml +2 -2
- package/dist/agent-src/profiles/finance.yml +1 -1
- package/dist/agent-src/profiles/founder.yml +2 -2
- package/dist/agent-src/profiles/ops.yml +2 -2
- package/dist/agent-src/rules/active-remediation.md +2 -0
- package/dist/agent-src/rules/architecture.md +4 -2
- package/dist/agent-src/rules/augment-edit-discipline.md +2 -0
- package/dist/agent-src/rules/autonomous-execution.md +1 -1
- package/dist/agent-src/rules/brand-consistency.md +10 -62
- package/dist/agent-src/rules/brand-source-of-truth.md +62 -11
- package/dist/agent-src/rules/broken-access-control.md +4 -0
- package/dist/agent-src/rules/cli-output-handling.md +5 -0
- package/dist/agent-src/rules/code-comment-discipline.md +3 -0
- package/dist/agent-src/rules/commit-conventions.md +2 -0
- package/dist/agent-src/rules/context-hygiene.md +3 -2
- package/dist/agent-src/rules/cross-source-consistency.md +3 -0
- package/dist/agent-src/rules/design-fidelity.md +2 -0
- package/dist/agent-src/rules/doc-screenshot-hygiene.md +2 -0
- package/dist/agent-src/rules/docker-commands.md +4 -0
- package/dist/agent-src/rules/domain-adoption-policy.md +2 -0
- package/dist/agent-src/rules/domain-safety-disclaimer.md +5 -2
- package/dist/agent-src/rules/domain-safety-pii.md +1 -1
- package/dist/agent-src/rules/engineering-safety-floor.md +2 -0
- package/dist/agent-src/rules/framework-neutrality-in-generic-skills.md +9 -0
- package/dist/agent-src/rules/image-likeness-and-rights.md +4 -0
- package/dist/agent-src/rules/improve-before-implement.md +4 -0
- package/dist/agent-src/rules/laravel-routing.md +4 -0
- package/dist/agent-src/rules/legal-safety-floor.md +3 -0
- package/dist/agent-src/rules/lethal-trifecta-guard.md +3 -0
- package/dist/agent-src/rules/media-governance-routing.md +5 -0
- package/dist/agent-src/rules/minimal-safe-diff.md +2 -0
- package/dist/agent-src/rules/no-roadmap-references.md +2 -0
- package/dist/agent-src/rules/notes-first-reasoning.md +2 -0
- package/dist/agent-src/rules/output-discipline.md +9 -2
- package/dist/agent-src/rules/php-coding.md +2 -0
- package/dist/agent-src/rules/prefer-enums-over-literals.md +3 -0
- package/dist/agent-src/rules/provider-lifecycle-discipline.md +5 -0
- package/dist/agent-src/rules/roadmap-ci-steps-policy.md +2 -0
- package/dist/agent-src/rules/roadmap-progress-sync.md +2 -0
- package/dist/agent-src/rules/rule-type-governance.md +2 -0
- package/dist/agent-src/rules/scale-discipline.md +3 -0
- package/dist/agent-src/rules/secret-vcs-guard.md +2 -0
- package/dist/agent-src/rules/security-sensitive-stop.md +9 -2
- package/dist/agent-src/rules/senior-engineering-discipline.md +6 -0
- package/dist/agent-src/rules/skill-quality.md +2 -0
- package/dist/agent-src/rules/source-confidentiality.md +4 -0
- package/dist/agent-src/rules/source-discovery-gate.md +3 -0
- package/dist/agent-src/rules/source-of-truth.md +2 -0
- package/dist/agent-src/rules/strategy-safety-floor.md +2 -0
- package/dist/agent-src/rules/think-before-action.md +5 -0
- package/dist/agent-src/rules/token-budget-discipline.md +2 -2
- package/dist/agent-src/rules/ui-audit-gate.md +2 -0
- package/dist/agent-src/rules/user-interaction.md +3 -4
- package/dist/agent-src/skills/build-buy-partner/SKILL.md +1 -1
- package/dist/agent-src/skills/copilot-agents-optimization/SKILL.md +4 -4
- package/dist/agent-src/skills/copilot-config/SKILL.md +1 -1
- package/dist/agent-src/skills/deep-reading-analyst/SKILL.md +7 -4
- package/dist/agent-src/skills/description-assist/SKILL.md +1 -1
- package/dist/agent-src/skills/design-intelligence/SKILL.md +6 -180
- package/dist/agent-src/skills/design-intelligence/references/context-and-registers.md +100 -0
- package/dist/agent-src/skills/design-intelligence/references/integration-mapping.md +91 -0
- package/dist/agent-src/skills/design-review/SKILL.md +4 -141
- package/dist/agent-src/skills/design-review/references/review-communication.md +92 -0
- package/dist/agent-src/skills/design-review/references/verification-automation.md +61 -0
- package/dist/agent-src/skills/existing-ui-audit/SKILL.md +8 -27
- package/dist/agent-src/skills/existing-ui-audit/references/anti-slop-cross-reference.md +31 -0
- package/dist/agent-src/skills/fe-design/SKILL.md +4 -289
- package/dist/agent-src/skills/fe-design/references/design-patterns.md +227 -0
- package/dist/agent-src/skills/fe-design/references/design-read-and-memory.md +75 -0
- package/dist/agent-src/skills/market-entry-analysis/SKILL.md +1 -1
- package/dist/agent-src/skills/persona-writing/SKILL.md +2 -2
- package/dist/agent-src/skills/readme-reviewer/SKILL.md +2 -1
- package/dist/agent-src/skills/roadmap-management/SKILL.md +10 -0
- package/dist/agent-src/skills/roadmap-writing/SKILL.md +12 -1
- package/dist/agent-src/skills/rule-writing/SKILL.md +4 -2
- package/dist/agent-src/skills/skill-reviewer/SKILL.md +1 -1
- package/dist/agent-src/skills/skill-writing/SKILL.md +2 -2
- package/dist/agent-src/skills/tailwind-engineer/SKILL.md +3 -1
- package/dist/agent-src/skills/token-optimizer/SKILL.md +2 -2
- package/dist/agent-src/skills/ui-component-architect/SKILL.md +6 -3
- package/dist/agent-src/templates/agent-settings.md +13 -15
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +6 -2
- package/dist/agent-src/templates/persona.md +2 -2
- package/dist/agent-src/templates/roadmaps.md +13 -1
- package/dist/agent-src/templates/rule.md +1 -1
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/_fix_lane.ts +52 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/audit.ts +8 -0
- package/dist/agent-src/templates/scripts/work_engine/directives/ui/design.ts +6 -0
- package/dist/agent-src/templates/scripts/work_engine/intent/classify.ts +56 -4
- package/dist/agent-src/templates/skill.md +1 -1
- package/dist/cli/registry.js +3 -0
- package/dist/cli/registry.js.map +1 -1
- package/dist/cli-delegate/chunk-AIIUU73N.js +2040 -0
- package/dist/cli-delegate/{chunk-ZXXJLL5K.js → chunk-BSLUHV2F.js} +127 -1487
- package/dist/cli-delegate/{chunk-H574KOUH.js → chunk-ELMFOQPW.js} +35 -1
- package/dist/cli-delegate/chunk-LF2KKJ4Q.js +183 -0
- package/dist/cli-delegate/chunk-VSYT7OHO.js +1382 -0
- package/dist/cli-delegate/chunk-XGA2NTU4.js +3727 -0
- package/dist/cli-delegate/cmd_conformance.js +4 -3
- package/dist/cli-delegate/cmd_converge.js +3 -3
- package/dist/cli-delegate/cmd_doctor.js +3 -2
- package/dist/cli-delegate/cmd_explain.js +36 -36
- package/dist/cli-delegate/cmd_export.js +4 -4
- package/dist/cli-delegate/cmd_handoff.js +1169 -0
- package/dist/cli-delegate/cmd_memory_get.js +35 -3754
- package/dist/cli-delegate/cmd_migrate.js +2 -2
- package/dist/cli-delegate/cmd_prune.js +4 -4
- package/dist/cli-delegate/cmd_route_audit.js +249 -0
- package/dist/cli-delegate/cmd_route_explain.js +285 -0
- package/dist/cli-delegate/cmd_settings_migrate.js +4 -4
- package/dist/cli-delegate/cmd_sync.js +4 -4
- package/dist/cli-delegate/cmd_uninstall.js +4 -4
- package/dist/cli-delegate/cmd_update.js +3 -3
- package/dist/cli-delegate/cmd_upgrade.js +3 -3
- package/dist/cli-delegate/cmd_validate.js +4 -4
- package/dist/cli-delegate/cmd_versions.js +3 -3
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +84 -84
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +1 -1
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +2 -2
- package/dist/discovery/trust-report.md +1 -1
- package/dist/discovery/workspaces.json +2 -2
- package/dist/hooks/dispatch.js +602 -507
- package/dist/install/install.mjs +34 -0
- package/dist/mcp/awesome-mcp-servers.row.md +1 -1
- package/dist/mcp/mcp-cloudflare-catalogue.json +2 -2
- package/dist/mcp/registry-manifest.json +4 -4
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +25 -3
- package/dist/router.json +1 -1
- package/dist/scripts/_lib/agent_src.js +39 -6
- package/dist/scripts/_lib/agent_src.js.map +1 -1
- package/dist/server/schemas/settings.js +25 -0
- package/dist/server/schemas/settings.js.map +1 -1
- package/docs/guidelines/abstraction-thresholds.md +53 -0
- package/docs/guidelines/agent-infra/agent-interaction-and-decision-quality.md +1 -1
- package/docs/guidelines/agent-infra/asking-and-brevity-examples.md +7 -0
- package/docs/guidelines/agent-infra/context-hygiene-mechanics.md +2 -2
- package/docs/guidelines/agent-infra/minimal-safe-diff-mechanics.md +5 -3
- package/docs/guidelines/agent-infra/size-and-scope.md +8 -2
- package/docs/guidelines/component-oriented-and-oop-development.md +11 -6
- package/docs/guidelines/docs/readme-size-and-splitting.md +5 -2
- package/llms.txt +1 -0
- package/package.json +1 -1
- package/src/agent-src/templates/scripts/work_engine/directives/ui/_fix_lane.ts +52 -0
- package/src/agent-src/templates/scripts/work_engine/directives/ui/audit.ts +8 -0
- package/src/agent-src/templates/scripts/work_engine/directives/ui/design.ts +6 -0
- package/src/agent-src/templates/scripts/work_engine/intent/classify.ts +56 -4
- package/src/config/agent-settings.template.yml +68 -0
- package/src/config/evaluator-budgets.json +8 -11
- package/src/config/gate-coverage.yml +70 -0
- package/src/scripts/_cli/cmd_explain.ts +41 -36
- package/src/scripts/_cli/cmd_handoff.ts +405 -0
- package/src/scripts/_cli/cmd_route_audit.ts +290 -0
- package/src/scripts/_cli/cmd_route_explain.ts +269 -0
- package/src/scripts/_cli/handoff_generate.ts +453 -0
- package/src/scripts/_cli/handoff_sessions.ts +435 -0
- package/src/scripts/_dispatch.bash +32 -0
- package/src/scripts/_lib/agent_src.ts +36 -6
- package/src/scripts/_lib/git_env.ts +40 -0
- package/src/scripts/_lib/md_table.ts +27 -0
- package/src/scripts/_lib/planning_settings.ts +43 -0
- package/src/scripts/_lib/release_material.ts +156 -0
- package/src/scripts/_lib/router_match.ts +301 -0
- package/src/scripts/annotate_r1_outcomes.ts +258 -0
- package/src/scripts/check_completion_review.ts +1140 -0
- package/src/scripts/check_condensation.ts +2 -1
- package/src/scripts/check_finding_dispositions.ts +278 -0
- package/src/scripts/check_pack_size.ts +4 -3
- package/src/scripts/check_references.ts +1 -0
- package/src/scripts/check_release_highlights.ts +300 -0
- package/src/scripts/check_release_pr_shape.ts +4 -0
- package/src/scripts/check_release_surface_equality.ts +132 -0
- package/src/scripts/check_reply_consistency.ts +187 -138
- package/src/scripts/compile_router.ts +20 -3
- package/src/scripts/dispatch_r2_reviewer.ts +968 -0
- package/src/scripts/eval_ui_triviality.ts +156 -0
- package/src/scripts/handoff_context_hook.ts +148 -0
- package/src/scripts/hook_manifest.yaml +17 -7
- package/src/scripts/hooks/concern_registry.ts +2 -0
- package/src/scripts/lint_abstraction_thresholds.ts +327 -0
- package/src/scripts/lint_framework_leakage_allowlist.json +2 -2
- package/src/scripts/lint_plan_risk_register.ts +931 -0
- package/src/scripts/lint_profile_personas.ts +153 -0
- package/src/scripts/lint_token_budget_discipline.ts +148 -0
- package/src/scripts/lint_trigger_collisions.ts +257 -0
- package/src/scripts/release.ts +156 -32
- package/src/scripts/release_drill.ts +491 -0
- package/src/scripts/router_telemetry.ts +16 -290
- package/src/scripts/schemas/command.schema.json +33 -0
- package/src/scripts/schemas/rule.schema.json +10 -0
- package/src/scripts/self_review_gate.ts +41 -3
- package/src/scripts/skill_linter.ts +3 -1
- package/src/scripts/smoke/router.sh +1 -1
- package/src/scripts/update_counts.ts +60 -12
- package/src/server/schemas/settings.ts +41 -0
- package/dist/cli-delegate/{chunk-XX6TOPD7.js → chunk-WR6GTRHJ.js} +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
main
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WR6GTRHJ.js";
|
|
5
5
|
import {
|
|
6
6
|
RULE_SOURCE_REL
|
|
7
7
|
} from "./chunk-BKO2AZ7Z.js";
|
|
@@ -5089,6 +5089,17 @@ var settingsSchema = external_exports.object({
|
|
|
5089
5089
|
'Optional planning horizon (weeks) the agent shows in roadmap framing ("next 4 weeks"). Set 0 to omit the horizon \u2014 most teams prefer to ship without a hardcoded window.'
|
|
5090
5090
|
)
|
|
5091
5091
|
}),
|
|
5092
|
+
planning: external_exports.object({
|
|
5093
|
+
challenge_on_create: external_exports.boolean().default(true).describe(
|
|
5094
|
+
"Gate C \u2014 plan-confidence gate before authoring. true (default) = a plan-artifact ask (/roadmap:create, roadmap-writing, /feature:plan, /feature:roadmap) first checks the four 95%-confidence conditions from /challenge-me vision; any gap routes into the interview (or the inline degrade protocol) before authoring, and a confident pass emits exactly one marker line. false = inert, plan asks author directly. An explicit user bypass always wins for that turn and is counted."
|
|
5095
|
+
),
|
|
5096
|
+
risk_review: external_exports.boolean().default(true).describe(
|
|
5097
|
+
'Gate R1 \u2014 plan-risk review. true (default) = every ready (non-draft) plan must carry a schema-valid "## Risk Register" section (ranked risks, mitigation + anchor per row, freshness marker, exact honest-null grammar), enforced by lint_plan_risk_register at pre-push + CI. false = escape hatch, the validator skips.'
|
|
5098
|
+
),
|
|
5099
|
+
completion_review: external_exports.boolean().default(true).describe(
|
|
5100
|
+
"Gate R2 \u2014 completion review at 100% roadmap completion / pre-PR. true (default) = a findings-before-fixes review by a fresh reviewer context must exist for the current diff hash (or an exact honest-null / skip declaration) before fix commits and PR creation, enforced by check_completion_review at pre-push + CI (CI authoritative; a crashed validator warns and allows). false = escape hatch, the validator skips."
|
|
5101
|
+
)
|
|
5102
|
+
}).default({}),
|
|
5092
5103
|
quality: external_exports.object({
|
|
5093
5104
|
local_auto_run: external_exports.boolean().default(false).describe(
|
|
5094
5105
|
"Run quality tools (linters, type-checks, formatters) and the local test suite autonomously after edits. Off by default \u2014 the agent never runs quality tools proactively and does not ask; the user runs them manually (e.g. /quality-fix) and remote CI is the authoritative gate. The agent only runs a quality tool on an explicit ask, a concrete CI failure, or the new-gate carve-out. Turn on to restore autonomous pipeline runs."
|
|
@@ -5131,6 +5142,29 @@ var settingsSchema = external_exports.object({
|
|
|
5131
5142
|
"Whether skills marked token_budget_class: rich may load in full (exempt from telegraph-speak + thin-projector trimming), consumed by the token-budget-discipline rule. on = allowed (default); off = fall back to standard condensed behavior; ask = surface an estimated token delta (tokens, not dollars) and ask once per session before loading."
|
|
5132
5143
|
)
|
|
5133
5144
|
}).default({ rich_skills: "on" }),
|
|
5145
|
+
verbosity: external_exports.object({
|
|
5146
|
+
intent_announcements: external_exports.boolean().default(false).describe(
|
|
5147
|
+
'Intent narration before tool batches ("Let me check X\u2026"). Only honored when personal.play_by_play is ALSO true (the direct-answers narration carve-out requires both). false (default) = act and emit the result.'
|
|
5148
|
+
),
|
|
5149
|
+
preview_artifacts: external_exports.boolean().default(false).describe(
|
|
5150
|
+
"Show generated commit messages, PR titles/bodies, branch names before acting. false (default) = use generated content directly (/commit terse path)."
|
|
5151
|
+
),
|
|
5152
|
+
routine_confirmations: external_exports.boolean().default(false).describe(
|
|
5153
|
+
"Confirmation prompts for routine workflow steps with one obvious answer. Iron-Law gates (commit-policy, scope-control git-ops, Hard Floor) ALWAYS ask regardless."
|
|
5154
|
+
),
|
|
5155
|
+
offer_council_in_delivery: external_exports.boolean().default(false).describe(
|
|
5156
|
+
'Offer "run AI Council on this?" inside delivery commands (/feature-plan, /review-changes, /roadmap-create). Council commands themselves are unaffected.'
|
|
5157
|
+
),
|
|
5158
|
+
post_action_reports: external_exports.enum(["off", "minimal", "full"]).default("minimal").describe(
|
|
5159
|
+
"Status blocks after a successful action. off = errors only; minimal (default) = one-line confirmation; full = bullet list."
|
|
5160
|
+
)
|
|
5161
|
+
}).default({
|
|
5162
|
+
intent_announcements: false,
|
|
5163
|
+
preview_artifacts: false,
|
|
5164
|
+
routine_confirmations: false,
|
|
5165
|
+
offer_council_in_delivery: false,
|
|
5166
|
+
post_action_reports: "minimal"
|
|
5167
|
+
}),
|
|
5134
5168
|
code_style: external_exports.object({
|
|
5135
5169
|
docblocks: external_exports.enum(["minimal", "full"]).default("minimal").describe(
|
|
5136
5170
|
"Consumed by the code-comment-discipline rule. minimal (default) = no signature-mirroring docblocks; docblocks only for machine-relevant precision (generics, array shapes) or genuine why-context. full = the exported public surface of a library package may carry one-line summary docblocks; the redundancy ban still holds."
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/scripts/_lib/router_match.ts
|
|
4
|
+
function _fnmatchToRegExp(pat) {
|
|
5
|
+
let res = "";
|
|
6
|
+
let i = 0;
|
|
7
|
+
const n = pat.length;
|
|
8
|
+
while (i < n) {
|
|
9
|
+
const c = pat[i];
|
|
10
|
+
i += 1;
|
|
11
|
+
if (c === "*") {
|
|
12
|
+
res += ".*";
|
|
13
|
+
} else if (c === "?") {
|
|
14
|
+
res += ".";
|
|
15
|
+
} else if (c === "[") {
|
|
16
|
+
let j = i;
|
|
17
|
+
if (j < n && pat[j] === "!") {
|
|
18
|
+
j += 1;
|
|
19
|
+
}
|
|
20
|
+
if (j < n && pat[j] === "]") {
|
|
21
|
+
j += 1;
|
|
22
|
+
}
|
|
23
|
+
while (j < n && pat[j] !== "]") {
|
|
24
|
+
j += 1;
|
|
25
|
+
}
|
|
26
|
+
if (j >= n) {
|
|
27
|
+
res += "\\[";
|
|
28
|
+
} else {
|
|
29
|
+
let stuff = pat.slice(i, j);
|
|
30
|
+
if (!stuff.includes("-")) {
|
|
31
|
+
stuff = stuff.replace(/\\/g, "\\\\");
|
|
32
|
+
} else {
|
|
33
|
+
const chunks = [];
|
|
34
|
+
let k = pat[i] === "!" ? i + 2 : i + 1;
|
|
35
|
+
let start = i;
|
|
36
|
+
while (true) {
|
|
37
|
+
const rel = pat.slice(k, j).indexOf("-");
|
|
38
|
+
if (rel < 0) {
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
const idx = k + rel;
|
|
42
|
+
chunks.push(pat.slice(start, idx));
|
|
43
|
+
start = idx + 1;
|
|
44
|
+
k = idx + 3;
|
|
45
|
+
}
|
|
46
|
+
chunks.push(pat.slice(start, j));
|
|
47
|
+
stuff = chunks.map((s) => s.replace(/\\/g, "\\\\").replace(/-/g, "\\-")).join("-");
|
|
48
|
+
}
|
|
49
|
+
stuff = stuff.replace(/([&~|])/g, "\\$1");
|
|
50
|
+
i = j + 1;
|
|
51
|
+
if (stuff.startsWith("!")) {
|
|
52
|
+
stuff = "^" + stuff.slice(1);
|
|
53
|
+
} else if (stuff.startsWith("^") || stuff.startsWith("[")) {
|
|
54
|
+
stuff = "\\" + stuff;
|
|
55
|
+
}
|
|
56
|
+
res += `[${stuff}]`;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
res += c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return new RegExp(`^(?:${res})$`, "s");
|
|
63
|
+
}
|
|
64
|
+
function _fnmatch(name, pat) {
|
|
65
|
+
return _fnmatchToRegExp(pat).test(name);
|
|
66
|
+
}
|
|
67
|
+
var _WORD_CHAR = /[\p{L}\p{N}_]/u;
|
|
68
|
+
function _isWordChar(c) {
|
|
69
|
+
return c !== void 0 && _WORD_CHAR.test(c);
|
|
70
|
+
}
|
|
71
|
+
function keyword_matches_anchored(prompt_lower, kw_lower) {
|
|
72
|
+
if (kw_lower === "") {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const needLeft = _isWordChar(kw_lower[0]);
|
|
76
|
+
const needRight = _isWordChar(kw_lower[kw_lower.length - 1]);
|
|
77
|
+
let idx = prompt_lower.indexOf(kw_lower);
|
|
78
|
+
while (idx !== -1) {
|
|
79
|
+
const leftOk = !needLeft || !_isWordChar(prompt_lower[idx - 1]);
|
|
80
|
+
let rightOk = true;
|
|
81
|
+
if (needRight) {
|
|
82
|
+
let end = idx + kw_lower.length;
|
|
83
|
+
if (prompt_lower[end] === "s") {
|
|
84
|
+
end += 1;
|
|
85
|
+
}
|
|
86
|
+
rightOk = !_isWordChar(prompt_lower[end]);
|
|
87
|
+
}
|
|
88
|
+
if (leftOk && rightOk) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
idx = prompt_lower.indexOf(kw_lower, idx + 1);
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
function trigger_matches(trigger, prompt, open_files, command) {
|
|
96
|
+
const prompt_lower = prompt.toLowerCase();
|
|
97
|
+
if ("keyword" in trigger) {
|
|
98
|
+
return keyword_matches_anchored(prompt_lower, String(trigger["keyword"]).toLowerCase());
|
|
99
|
+
}
|
|
100
|
+
if ("phrase" in trigger) {
|
|
101
|
+
return prompt_lower.includes(String(trigger["phrase"]).toLowerCase());
|
|
102
|
+
}
|
|
103
|
+
if ("command" in trigger) {
|
|
104
|
+
if (!command) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return command.startsWith(String(trigger["command"]));
|
|
108
|
+
}
|
|
109
|
+
if ("path_prefix" in trigger) {
|
|
110
|
+
if (!open_files) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
const pref = String(trigger["path_prefix"]);
|
|
114
|
+
for (const p of open_files) {
|
|
115
|
+
if (String(p).startsWith(pref)) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if ("file_pattern" in trigger) {
|
|
122
|
+
if (!open_files) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
const pat = String(trigger["file_pattern"]);
|
|
126
|
+
for (const p of open_files) {
|
|
127
|
+
if (_fnmatch(String(p), pat)) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
function _asRuleList(value) {
|
|
136
|
+
if (!Array.isArray(value)) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
function _asTriggerList(value) {
|
|
142
|
+
if (!Array.isArray(value)) {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
function match_prompt(router, prompt, profile = "full", open_files, command) {
|
|
148
|
+
const tiers = [
|
|
149
|
+
["tier_1", _asRuleList(router["tier_1"])]
|
|
150
|
+
];
|
|
151
|
+
if (profile === "full") {
|
|
152
|
+
tiers.push(["tier_2", _asRuleList(router["tier_2"])]);
|
|
153
|
+
}
|
|
154
|
+
const matched_triggers = [];
|
|
155
|
+
const activated_rules = [];
|
|
156
|
+
for (const [tier_name, rules] of tiers) {
|
|
157
|
+
for (const rule of rules) {
|
|
158
|
+
const rule_id = rule["id"];
|
|
159
|
+
const rule_triggers = _asTriggerList(rule["triggers"]);
|
|
160
|
+
let rule_hit = false;
|
|
161
|
+
for (const trig of rule_triggers) {
|
|
162
|
+
if (trigger_matches(trig, prompt, open_files, command)) {
|
|
163
|
+
matched_triggers.push({ tier: tier_name, rule: rule_id, trigger: trig });
|
|
164
|
+
rule_hit = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (rule_hit) {
|
|
168
|
+
activated_rules.push({ tier: tier_name, rule: rule_id });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const kernel = Array.isArray(router["kernel"]) ? router["kernel"] : [];
|
|
173
|
+
for (const kid of kernel) {
|
|
174
|
+
activated_rules.push({ tier: "kernel", rule: kid });
|
|
175
|
+
}
|
|
176
|
+
return { matched_triggers, activated_rules };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
trigger_matches,
|
|
181
|
+
_asRuleList,
|
|
182
|
+
match_prompt
|
|
183
|
+
};
|