@dyyz1993/pi-coding-agent 0.74.25 → 0.74.28
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 +9 -0
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +45 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/types.d.ts +17 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/session-manager.d.ts +5 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +8 -0
- package/dist/core/session-manager.js.map +1 -1
- package/dist/extensions/hooks-engine/index.ts +104 -16
- package/dist/extensions/lsp/lsp/index.ts +40 -37
- package/dist/extensions/output-guard/index.ts +126 -64
- package/dist/extensions/rules-engine/index.js +64 -22
- package/dist/extensions/rules-engine/index.ts +86 -16
- package/dist/extensions/rules-engine/types.d.ts +12 -2
- package/dist/extensions/rules-engine/types.d.ts.map +1 -1
- package/dist/extensions/rules-engine/types.js.map +1 -1
- package/dist/extensions/rules-engine/types.ts +13 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
MatchRecord,
|
|
12
12
|
ParsedRule,
|
|
13
13
|
RuleDetail,
|
|
14
|
+
RuleMatchStatus,
|
|
14
15
|
RuleSeverity,
|
|
15
16
|
RulesChannelContract,
|
|
16
17
|
RulesChannelEvent,
|
|
@@ -54,8 +55,21 @@ export default function rulesEnginePlugin(pi: ExtensionAPI) {
|
|
|
54
55
|
let hasSentSnapshot = false;
|
|
55
56
|
let _lastCwd = "";
|
|
56
57
|
let lastMessages: unknown[] = [];
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
/** Track which rule+file combos have been injected.
|
|
60
|
+
* Forward index: ruleName → Map<filePath, toolCallId>
|
|
61
|
+
* The toolCallId is the ID of the tool call that injected this rule+file combo,
|
|
62
|
+
* used to correlate with entries_invalidated events for precise cleanup. */
|
|
63
|
+
let injectedRuleFiles: Map<string, Map<string, string>> = new Map();
|
|
64
|
+
|
|
65
|
+
/** Reverse index: toolCallId → Array<{ ruleName, filePath }>
|
|
66
|
+
* Used to quickly find and remove entries when entries_invalidated fires. */
|
|
67
|
+
let injectionByToolCallId: Map<string, Array<{ ruleName: string; filePath: string }>> = new Map();
|
|
68
|
+
|
|
69
|
+
/** Set of toolCallIds whose entries have been invalidated (deleted/folded/summarized).
|
|
70
|
+
* When checking alreadyLoaded status, if the previous toolCallId is in this set,
|
|
71
|
+
* we mark the rule as "reloaded" instead of "already_loaded". */
|
|
72
|
+
let invalidatedToolCallIds: Set<string> = new Set();
|
|
59
73
|
|
|
60
74
|
function rebuildMatchHistory(messages: unknown[]): MatchRecord[] {
|
|
61
75
|
const history: MatchRecord[] = [];
|
|
@@ -414,10 +428,21 @@ export default function rulesEnginePlugin(pi: ExtensionAPI) {
|
|
|
414
428
|
const matching = getMatchingRules(targetPath);
|
|
415
429
|
if (matching.length === 0) return undefined;
|
|
416
430
|
|
|
431
|
+
// Determine status for each rule: loaded / already_loaded / reloaded
|
|
417
432
|
const matchedRuleDetails: MatchedRuleDetail[] = matching.map((r) => {
|
|
418
433
|
const ruleName = r.name;
|
|
419
|
-
const
|
|
420
|
-
const
|
|
434
|
+
const fileMap = injectedRuleFiles.get(ruleName);
|
|
435
|
+
const isInMap = fileMap !== undefined && fileMap.has(targetPath);
|
|
436
|
+
|
|
437
|
+
let status: RuleMatchStatus;
|
|
438
|
+
if (!isInMap) {
|
|
439
|
+
status = "loaded"; // never injected before
|
|
440
|
+
} else {
|
|
441
|
+
// Was in map — check if the injection was invalidated
|
|
442
|
+
const previousCallId = fileMap.get(targetPath)!;
|
|
443
|
+
const wasInvalidated = invalidatedToolCallIds.has(previousCallId);
|
|
444
|
+
status = wasInvalidated ? "reloaded" : "already_loaded";
|
|
445
|
+
}
|
|
421
446
|
|
|
422
447
|
return {
|
|
423
448
|
name: ruleName,
|
|
@@ -427,30 +452,48 @@ export default function rulesEnginePlugin(pi: ExtensionAPI) {
|
|
|
427
452
|
(r.frontmatter.globs ?? r.frontmatter.paths)?.find((p) => matchesAnyGlob([p], targetPath)) ||
|
|
428
453
|
(r.frontmatter.globs ?? r.frontmatter.paths)?.[0] ||
|
|
429
454
|
"",
|
|
430
|
-
|
|
455
|
+
status,
|
|
456
|
+
alreadyLoaded: status === "already_loaded" || undefined,
|
|
431
457
|
};
|
|
432
458
|
});
|
|
433
459
|
|
|
434
|
-
//
|
|
435
|
-
const newRules = matching.filter((
|
|
436
|
-
const
|
|
437
|
-
return
|
|
460
|
+
// Rules that need (re-)injection: loaded or reloaded
|
|
461
|
+
const newRules = matching.filter((_r, i) => {
|
|
462
|
+
const s = matchedRuleDetails[i].status;
|
|
463
|
+
return s === "loaded" || s === "reloaded";
|
|
438
464
|
});
|
|
439
465
|
const allAlreadyLoaded = newRules.length === 0;
|
|
440
466
|
|
|
441
467
|
// Record that these rules have now been injected for this file
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
468
|
+
const toolCallId = event.toolCallId;
|
|
469
|
+
for (let i = 0; i < matching.length; i++) {
|
|
470
|
+
const ruleName = matching[i].name;
|
|
471
|
+
let fileMap = injectedRuleFiles.get(ruleName);
|
|
472
|
+
if (!fileMap) {
|
|
473
|
+
fileMap = new Map();
|
|
474
|
+
injectedRuleFiles.set(ruleName, fileMap);
|
|
475
|
+
}
|
|
476
|
+
fileMap.set(targetPath, toolCallId);
|
|
477
|
+
|
|
478
|
+
// Update reverse index
|
|
479
|
+
let reverseEntries = injectionByToolCallId.get(toolCallId);
|
|
480
|
+
if (!reverseEntries) {
|
|
481
|
+
reverseEntries = [];
|
|
482
|
+
injectionByToolCallId.set(toolCallId, reverseEntries);
|
|
483
|
+
}
|
|
484
|
+
// Avoid duplicates for same rule+file on same toolCallId
|
|
485
|
+
if (!reverseEntries.some((e) => e.ruleName === ruleName && e.filePath === targetPath)) {
|
|
486
|
+
reverseEntries.push({ ruleName, filePath: targetPath });
|
|
447
487
|
}
|
|
448
|
-
injectedFiles.add(targetPath);
|
|
449
488
|
}
|
|
450
489
|
|
|
451
490
|
const hasCritical = matching.some((r) => r.frontmatter.severity === "critical");
|
|
452
491
|
const hasHigh = matching.some((r) => r.frontmatter.severity === "high");
|
|
453
492
|
|
|
493
|
+
// Determine overall status for the payload
|
|
494
|
+
const overallStatus: RuleMatchStatus | undefined =
|
|
495
|
+
allAlreadyLoaded ? "already_loaded" : matchedRuleDetails.every((d) => d.status === "reloaded") ? "reloaded" : "loaded";
|
|
496
|
+
|
|
454
497
|
channel.emit("matched", {
|
|
455
498
|
type: "matched",
|
|
456
499
|
filePath: targetPath,
|
|
@@ -459,10 +502,11 @@ export default function rulesEnginePlugin(pi: ExtensionAPI) {
|
|
|
459
502
|
toolCallId: event.toolCallId,
|
|
460
503
|
severity: hasCritical ? "warning" : hasHigh ? "warning" : "info",
|
|
461
504
|
timestamp: Date.now(),
|
|
505
|
+
status: overallStatus,
|
|
462
506
|
alreadyLoaded: allAlreadyLoaded || undefined,
|
|
463
507
|
});
|
|
464
508
|
|
|
465
|
-
// Only inject content for
|
|
509
|
+
// Only inject content for rules that are loaded or reloaded (skip if all already loaded)
|
|
466
510
|
if (allAlreadyLoaded) {
|
|
467
511
|
return {
|
|
468
512
|
details: {
|
|
@@ -515,6 +559,8 @@ export default function rulesEnginePlugin(pi: ExtensionAPI) {
|
|
|
515
559
|
cachedMatchHash = "";
|
|
516
560
|
lastMessages = [];
|
|
517
561
|
injectedRuleFiles = new Map();
|
|
562
|
+
injectionByToolCallId = new Map();
|
|
563
|
+
invalidatedToolCallIds = new Set();
|
|
518
564
|
ctx.ui.setStatus("rules-engine", `Rules: ${rules.length} (re-injected after compact)`);
|
|
519
565
|
});
|
|
520
566
|
|
|
@@ -522,6 +568,30 @@ export default function rulesEnginePlugin(pi: ExtensionAPI) {
|
|
|
522
568
|
cachedMatchHash = "";
|
|
523
569
|
lastMessages = [];
|
|
524
570
|
injectedRuleFiles = new Map();
|
|
571
|
+
injectionByToolCallId = new Map();
|
|
572
|
+
invalidatedToolCallIds = new Set();
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
pi.on("entries_invalidated", async (event) => {
|
|
576
|
+
const eventToolCallIds = event.invalidatedToolCallIds;
|
|
577
|
+
if (eventToolCallIds.length === 0) return;
|
|
578
|
+
|
|
579
|
+
// Mark affected toolCallIds as invalidated so next tool_result
|
|
580
|
+
// can distinguish "reloaded" from "already_loaded"
|
|
581
|
+
for (const callId of eventToolCallIds) {
|
|
582
|
+
if (injectionByToolCallId.has(callId)) {
|
|
583
|
+
invalidatedToolCallIds.add(callId);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// Also scan forward map to find any tracked toolCallId that was invalidated
|
|
588
|
+
for (const [_ruleName, fileMap] of injectedRuleFiles) {
|
|
589
|
+
for (const [_filePath, trackedCallId] of fileMap) {
|
|
590
|
+
if (eventToolCallIds.includes(trackedCallId)) {
|
|
591
|
+
invalidatedToolCallIds.add(trackedCallId);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
525
595
|
});
|
|
526
596
|
|
|
527
597
|
pi.on("turn_end", async () => {
|
|
@@ -65,12 +65,20 @@ export interface ScannedDir {
|
|
|
65
65
|
fileCount: number;
|
|
66
66
|
ruleNames: string[];
|
|
67
67
|
}
|
|
68
|
+
export type RuleMatchStatus = "loaded" | "already_loaded" | "reloaded";
|
|
68
69
|
export interface MatchedRuleDetail {
|
|
69
70
|
name: string;
|
|
70
71
|
title: string;
|
|
71
72
|
severity: RuleSeverity;
|
|
72
73
|
matchedGlob: string;
|
|
73
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Match status:
|
|
76
|
+
* - "loaded": first time injected for this file
|
|
77
|
+
* - "already_loaded": previously injected and still in context (skipped)
|
|
78
|
+
* - "reloaded": previously injected but was invalidated (context removed), now re-injected
|
|
79
|
+
*/
|
|
80
|
+
status?: RuleMatchStatus;
|
|
81
|
+
/** @deprecated Use status instead. True when this rule was already injected for the same file. */
|
|
74
82
|
alreadyLoaded?: boolean;
|
|
75
83
|
}
|
|
76
84
|
export interface MatchRecord {
|
|
@@ -117,7 +125,9 @@ export interface MatchedPayload {
|
|
|
117
125
|
toolCallId: string;
|
|
118
126
|
severity: "info" | "warning";
|
|
119
127
|
timestamp: number;
|
|
120
|
-
/**
|
|
128
|
+
/** Overall match status when all rules share the same state */
|
|
129
|
+
status?: RuleMatchStatus;
|
|
130
|
+
/** @deprecated Use status instead */
|
|
121
131
|
alreadyLoaded?: boolean;
|
|
122
132
|
}
|
|
123
133
|
export interface InjectedPayload {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3E,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EA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jB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAAG,cAAc,GAAG,eAAe,GAAG,eAAe,GAAG,eAAe,CAAC;AAEvH,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE;QACR,WAAW,EAAE;YACZ,MAAM,EAAE;gBAAE,GAAG,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YACzB,MAAM,EAAE,eAAe,CAAC;SACxB,CAAC;KACF,CAAC;IACF,MAAM,EAAE;QACP,QAAQ,EAAE,eAAe,CAAC;QAC1B,OAAO,EAAE,cAAc,CAAC;QACxB,QAAQ,EAAE,eAAe,CAAC;QAC1B,QAAQ,EAAE,eAAe,CAAC;QAC1B,QAAQ,EAAE,eAAe,CAAC;KAC1B,CAAC;CACF","sourcesContent":["export type RuleSeverity = \"critical\" | \"high\" | \"medium\" | \"low\" | \"hint\";\n\nexport type RuleScope = \"user\" | \"pi\" | \"project\" | \"managed\";\n\nexport interface RuleFrontmatter {\n\tglobs?: string[];\n\tpaths?: string[];\n\tdescription?: string;\n\tseverity?: RuleSeverity;\n\tallowedTools?: string[];\n\twhenToUse?: string;\n\tversion?: string;\n\tmodel?: string;\n\tskills?: string;\n\teffort?: string;\n\tuserInvocable?: string;\n\tcontext?: \"inline\" | \"fork\";\n\tagent?: string;\n\tshell?: string;\n\tnotifyOnMatch?: boolean;\n\tskipInPrompt?: boolean;\n}\n\nexport interface ParsedRule {\n\tname: string;\n\tfilePath: string;\n\ttitle: string;\n\tcontent: string;\n\tscope: RuleScope;\n\tsource: string;\n\tfrontmatter: RuleFrontmatter;\n\tisUnconditional: boolean;\n}\n\nexport interface RuleCache {\n\trules: ParsedRule[];\n\tunconditional: ParsedRule[];\n\tconditional: ParsedRule[];\n\tloadedAt: number;\n}\n\nexport interface CachedRules {\n\trules: ParsedRule[];\n\tloadedAt: number;\n}\n\nexport interface RulesConfig {\n\tcacheTTL: number;\n\tnotifyOnLoad: boolean;\n\tnotifyOnMatch: boolean;\n\tdirs?: {\n\t\tuser?: string[];\n\t\tpi?: string[];\n\t\tproject?: string[];\n\t\tmanaged?: string[];\n\t};\n}\n\nexport interface RuleDetail {\n\tname: string;\n\ttitle: string;\n\tfilePath: string;\n\tscope: RuleScope;\n\tsource: string;\n\tseverity: RuleSeverity;\n\tisUnconditional: boolean;\n\tglobs: string[];\n\tdescription?: string;\n}\n\nexport interface ScannedDir {\n\tdir: string;\n\tfileCount: number;\n\truleNames: string[];\n}\n\nexport type RuleMatchStatus = \"loaded\" | \"already_loaded\" | \"reloaded\";\n\nexport interface MatchedRuleDetail {\n\tname: string;\n\ttitle: string;\n\tseverity: RuleSeverity;\n\tmatchedGlob: string;\n\t/**\n\t * Match status:\n\t * - \"loaded\": first time injected for this file\n\t * - \"already_loaded\": previously injected and still in context (skipped)\n\t * - \"reloaded\": previously injected but was invalidated (context removed), now re-injected\n\t */\n\tstatus?: RuleMatchStatus;\n\t/** @deprecated Use status instead. True when this rule was already injected for the same file. */\n\talreadyLoaded?: boolean;\n}\n\nexport interface MatchRecord {\n\tfilePath: string;\n\truleNames: string[];\n\ttoolName: string;\n\ttoolCallId: string;\n\tseverity: \"info\" | \"warning\";\n\ttimestamp: number;\n\tmatchedRuleDetails?: MatchedRuleDetail[];\n}\n\nexport interface LifecycleEntry {\n\tevent: \"loaded\" | \"restored\" | \"injected\" | \"reloaded\" | \"unloaded\" | \"expired\";\n\tmessage: string;\n\truleCount?: number;\n\ttimestamp: number;\n\tdetails?: {\n\t\tscannedDirs?: ScannedDir[];\n\t\tconfigSource?: string;\n\t\tcacheHit?: boolean;\n\t\tinjectedRules?: Array<{ name: string; promptDelta: number }>;\n\t};\n}\n\nexport interface SnapshotPayload {\n\ttype: \"snapshot\";\n\trules: RuleDetail[];\n\tinjectedRuleNames: string[];\n\ttotalRules: number;\n\tunconditionalCount: number;\n\tconditionalCount: number;\n\tmatchHistory: MatchRecord[];\n\tlifecycleLog: LifecycleEntry[];\n\tloadedAt: number;\n\tcacheTTL: number;\n}\n\nexport interface MatchedPayload {\n\ttype: \"matched\";\n\tfilePath: string;\n\tmatchedRules: MatchedRuleDetail[];\n\ttoolName: string;\n\ttoolCallId: string;\n\tseverity: \"info\" | \"warning\";\n\ttimestamp: number;\n\t/** Overall match status when all rules share the same state */\n\tstatus?: RuleMatchStatus;\n\t/** @deprecated Use status instead */\n\talreadyLoaded?: boolean;\n}\n\nexport interface InjectedPayload {\n\ttype: \"injected\";\n\truleNames: string[];\n\tsystemPromptLength: number;\n}\n\nexport interface ReloadedPayload {\n\ttype: \"reloaded\";\n\trules: RuleDetail[];\n\tloadedAt: number;\n}\n\nexport interface UnloadedPayload {\n\ttype: \"unloaded\";\n\treason: string;\n}\n\nexport type RulesChannelEvent = SnapshotPayload | MatchedPayload | InjectedPayload | ReloadedPayload | UnloadedPayload;\n\nexport const RULES_CHANNEL_NAME = \"rules-engine\";\n\nexport interface RulesChannelContract {\n\tmethods: {\n\t\tgetSnapshot: {\n\t\t\tparams: { cwd?: string };\n\t\t\treturn: SnapshotPayload;\n\t\t};\n\t};\n\tevents: {\n\t\tsnapshot: SnapshotPayload;\n\t\tmatched: MatchedPayload;\n\t\tinjected: InjectedPayload;\n\t\treloaded: ReloadedPayload;\n\t\tunloaded: UnloadedPayload;\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAmKA,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC","sourcesContent":["export type RuleSeverity = \"critical\" | \"high\" | \"medium\" | \"low\" | \"hint\";\n\nexport type RuleScope = \"user\" | \"pi\" | \"project\" | \"managed\";\n\nexport interface RuleFrontmatter {\n\tglobs?: string[];\n\tpaths?: string[];\n\tdescription?: string;\n\tseverity?: RuleSeverity;\n\tallowedTools?: string[];\n\twhenToUse?: string;\n\tversion?: string;\n\tmodel?: string;\n\tskills?: string;\n\teffort?: string;\n\tuserInvocable?: string;\n\tcontext?: \"inline\" | \"fork\";\n\tagent?: string;\n\tshell?: string;\n\tnotifyOnMatch?: boolean;\n\tskipInPrompt?: boolean;\n}\n\nexport interface ParsedRule {\n\tname: string;\n\tfilePath: string;\n\ttitle: string;\n\tcontent: string;\n\tscope: RuleScope;\n\tsource: string;\n\tfrontmatter: RuleFrontmatter;\n\tisUnconditional: boolean;\n}\n\nexport interface RuleCache {\n\trules: ParsedRule[];\n\tunconditional: ParsedRule[];\n\tconditional: ParsedRule[];\n\tloadedAt: number;\n}\n\nexport interface CachedRules {\n\trules: ParsedRule[];\n\tloadedAt: number;\n}\n\nexport interface RulesConfig {\n\tcacheTTL: number;\n\tnotifyOnLoad: boolean;\n\tnotifyOnMatch: boolean;\n\tdirs?: {\n\t\tuser?: string[];\n\t\tpi?: string[];\n\t\tproject?: string[];\n\t\tmanaged?: string[];\n\t};\n}\n\nexport interface RuleDetail {\n\tname: string;\n\ttitle: string;\n\tfilePath: string;\n\tscope: RuleScope;\n\tsource: string;\n\tseverity: RuleSeverity;\n\tisUnconditional: boolean;\n\tglobs: string[];\n\tdescription?: string;\n}\n\nexport interface ScannedDir {\n\tdir: string;\n\tfileCount: number;\n\truleNames: string[];\n}\n\nexport type RuleMatchStatus = \"loaded\" | \"already_loaded\" | \"reloaded\";\n\nexport interface MatchedRuleDetail {\n\tname: string;\n\ttitle: string;\n\tseverity: RuleSeverity;\n\tmatchedGlob: string;\n\t/**\n\t * Match status:\n\t * - \"loaded\": first time injected for this file\n\t * - \"already_loaded\": previously injected and still in context (skipped)\n\t * - \"reloaded\": previously injected but was invalidated (context removed), now re-injected\n\t */\n\tstatus?: RuleMatchStatus;\n\t/** @deprecated Use status instead. True when this rule was already injected for the same file. */\n\talreadyLoaded?: boolean;\n}\n\nexport interface MatchRecord {\n\tfilePath: string;\n\truleNames: string[];\n\ttoolName: string;\n\ttoolCallId: string;\n\tseverity: \"info\" | \"warning\";\n\ttimestamp: number;\n\tmatchedRuleDetails?: MatchedRuleDetail[];\n}\n\nexport interface LifecycleEntry {\n\tevent: \"loaded\" | \"restored\" | \"injected\" | \"reloaded\" | \"unloaded\" | \"expired\";\n\tmessage: string;\n\truleCount?: number;\n\ttimestamp: number;\n\tdetails?: {\n\t\tscannedDirs?: ScannedDir[];\n\t\tconfigSource?: string;\n\t\tcacheHit?: boolean;\n\t\tinjectedRules?: Array<{ name: string; promptDelta: number }>;\n\t};\n}\n\nexport interface SnapshotPayload {\n\ttype: \"snapshot\";\n\trules: RuleDetail[];\n\tinjectedRuleNames: string[];\n\ttotalRules: number;\n\tunconditionalCount: number;\n\tconditionalCount: number;\n\tmatchHistory: MatchRecord[];\n\tlifecycleLog: LifecycleEntry[];\n\tloadedAt: number;\n\tcacheTTL: number;\n}\n\nexport interface MatchedPayload {\n\ttype: \"matched\";\n\tfilePath: string;\n\tmatchedRules: MatchedRuleDetail[];\n\ttoolName: string;\n\ttoolCallId: string;\n\tseverity: \"info\" | \"warning\";\n\ttimestamp: number;\n\t/** Overall match status when all rules share the same state */\n\tstatus?: RuleMatchStatus;\n\t/** @deprecated Use status instead */\n\talreadyLoaded?: boolean;\n}\n\nexport interface InjectedPayload {\n\ttype: \"injected\";\n\truleNames: string[];\n\tsystemPromptLength: number;\n}\n\nexport interface ReloadedPayload {\n\ttype: \"reloaded\";\n\trules: RuleDetail[];\n\tloadedAt: number;\n}\n\nexport interface UnloadedPayload {\n\ttype: \"unloaded\";\n\treason: string;\n}\n\nexport type RulesChannelEvent = SnapshotPayload | MatchedPayload | InjectedPayload | ReloadedPayload | UnloadedPayload;\n\nexport const RULES_CHANNEL_NAME = \"rules-engine\";\n\nexport interface RulesChannelContract {\n\tmethods: {\n\t\tgetSnapshot: {\n\t\t\tparams: { cwd?: string };\n\t\t\treturn: SnapshotPayload;\n\t\t};\n\t};\n\tevents: {\n\t\tsnapshot: SnapshotPayload;\n\t\tmatched: MatchedPayload;\n\t\tinjected: InjectedPayload;\n\t\treloaded: ReloadedPayload;\n\t\tunloaded: UnloadedPayload;\n\t};\n}\n"]}
|
|
@@ -74,12 +74,21 @@ export interface ScannedDir {
|
|
|
74
74
|
ruleNames: string[];
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
export type RuleMatchStatus = "loaded" | "already_loaded" | "reloaded";
|
|
78
|
+
|
|
77
79
|
export interface MatchedRuleDetail {
|
|
78
80
|
name: string;
|
|
79
81
|
title: string;
|
|
80
82
|
severity: RuleSeverity;
|
|
81
83
|
matchedGlob: string;
|
|
82
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Match status:
|
|
86
|
+
* - "loaded": first time injected for this file
|
|
87
|
+
* - "already_loaded": previously injected and still in context (skipped)
|
|
88
|
+
* - "reloaded": previously injected but was invalidated (context removed), now re-injected
|
|
89
|
+
*/
|
|
90
|
+
status?: RuleMatchStatus;
|
|
91
|
+
/** @deprecated Use status instead. True when this rule was already injected for the same file. */
|
|
83
92
|
alreadyLoaded?: boolean;
|
|
84
93
|
}
|
|
85
94
|
|
|
@@ -127,7 +136,9 @@ export interface MatchedPayload {
|
|
|
127
136
|
toolCallId: string;
|
|
128
137
|
severity: "info" | "warning";
|
|
129
138
|
timestamp: number;
|
|
130
|
-
/**
|
|
139
|
+
/** Overall match status when all rules share the same state */
|
|
140
|
+
status?: RuleMatchStatus;
|
|
141
|
+
/** @deprecated Use status instead */
|
|
131
142
|
alreadyLoaded?: boolean;
|
|
132
143
|
}
|
|
133
144
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.74.
|
|
3
|
+
"version": "0.74.16",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.74.
|
|
9
|
+
"version": "0.74.16",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.16",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "1.4.
|
|
9
|
+
"version": "1.4.16",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "0.74.
|
|
3
|
+
"version": "0.74.16",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "0.74.
|
|
9
|
+
"version": "0.74.16",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyyz1993/pi-coding-agent",
|
|
3
|
-
"version": "0.74.
|
|
3
|
+
"version": "0.74.28",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"prepublishOnly": "npm run clean && npm run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@dyyz1993/pi-agent-core": "^0.74.
|
|
43
|
-
"@dyyz1993/pi-ai": "^0.74.
|
|
44
|
-
"@dyyz1993/pi-tui": "^0.74.
|
|
42
|
+
"@dyyz1993/pi-agent-core": "^0.74.27",
|
|
43
|
+
"@dyyz1993/pi-ai": "^0.74.27",
|
|
44
|
+
"@dyyz1993/pi-tui": "^0.74.27",
|
|
45
45
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
46
46
|
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
47
47
|
"chalk": "^5.5.0",
|