create-principles-disciple 1.121.0 → 1.121.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-principles-disciple",
|
|
3
|
-
"version": "1.121.
|
|
3
|
+
"version": "1.121.1",
|
|
4
4
|
"description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -62,6 +62,6 @@
|
|
|
62
62
|
"directory": "packages/create-principles-disciple"
|
|
63
63
|
},
|
|
64
64
|
"pd": {
|
|
65
|
-
"bundledPluginVersion": "1.
|
|
65
|
+
"bundledPluginVersion": "1.219.0"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/plugin/dist/bundle.js
CHANGED
|
@@ -2607,7 +2607,7 @@ Reason: ${t}
|
|
|
2607
2607
|
This action was blocked by a Rule Host principle.
|
|
2608
2608
|
If the blocked path is correct and safe, explain the reasoning to the owner
|
|
2609
2609
|
and ask for explicit confirmation to proceed.
|
|
2610
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`}function hFt(e,t,r,n,o){if(r>3){o(`[PD_GATE] Failed to persist trajectory gate block after ${3} retries: ${t.toolName} ${t.filePath}`);return}setTimeout(()=>{try{e.trajectory?.recordGateBlock?.(t),n(`[PD_GATE] Trajectory gate block persisted on retry ${r}`)}catch(i){n(`[PD_GATE] Retrying trajectory gate block persistence (attempt ${r+1}): ${String(i)}`),hFt(e,t,r+1,n,o)}},250*r).unref()}var vDn=new Set(["success","failure","blocked"]),TDn=20;function EDn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function RDn(e){return typeof e=="string"&&vDn.has(e)}function wDn(e,t,r){let n=[];for(let o of e){let i=o.toolName;if(typeof i!="string"||i.length===0)return lP(`row id=${o.id}: tool_name must be a non-empty string`);let a=o.outcome;if(!RDn(a))return lP(`row id=${o.id}: outcome "${o.outcome}" is not a valid RuleToolOutcome`);let s=o.paramsJson;if(typeof s!="string")return lP(`row id=${o.id}: params_json must be a string`);let c;try{c=JSON.parse(s)}catch{return lP(`row id=${o.id}: params_json is not valid JSON`)}if(!EDn(c))return lP(`row id=${o.id}: params_json must parse to a non-array object`);let u=WN(i),l=AJ(c,{isBashTool:u==="execute",isWriteTool:u==="write",toolName:i}),d=kJ(l,r);n.push({sequenceId:o.id,toolName:i,canonicalKind:u,normalizedPath:d===""?null:d,paramsSummary:c,outcome:a})}return{status:"available",truncated:t,calls:n}}function gFt(e,t,r,n,o=TDn){if(!e||typeof e!="string"||e.length===0)return Vf;try{let i=r.getRuleHostContextRows(e,o),a=wDn(i.rows,i.truncated,n),s=Ote(a,t,null);return{version:2,history:a,facts:s}}catch{return IDn("query or assembly failed")}}function lP(e){return{status:"unavailable",unavailableReason:e,truncated:!1,calls:[]}}function IDn(e){return{version:2,history:lP(e),facts:{priorReadOfTarget:"unknown",readCount:null,writeCount:null,uniqueWritePathCount:null,sameActionBlockCount:null}}}function jke(e,t){let r=t.logger||console,n=rQ.has(e.toolName),o=kke.has(e.toolName),i=V2t.has(e.toolName);if(!t.workspaceDir||!o&&!n&&!i)return;let a=rr.fromHookContext(t),s=Xx(e.toolName,e.params??{},a.workspaceDir,{isBashTool:n,isWriteTool:o}),c=s.normalizedPath;if(c!==null)try{let u=a.getRuleHost(r),l=Gke(a,c,t.sessionId,r),d={action:s,workspace:{isRiskPath:!1},session:{sessionId:t.sessionId,currentGfi:_Ft(t.sessionId)},evolution:{epTier:yFt(a.workspaceDir)},derived:{estimatedLineChanges:FO({toolName:e.toolName,params:e.params??{}}),bashRisk:SFt(e)},context:l},p=typeof u.evaluateDetailed=="function"?u.evaluateDetailed(d):{liveDecision:u.evaluate(d),shadowDecisions:[],skippedActivations:[]},m=p.liveDecision;if(jY({workspaceDir:a.workspaceDir,activationId:p.liveDecisionActivationId,toolName:e.toolName,params:e.params??{},decision:m?.decision??"allow",matched:m?.matched??!1,logger:r})){r.warn?.(`[PD_GATE] RuleCode ${p.liveDecisionActivationId??"unknown"} safety-isolated; allowing current host call.`);return}for(let g of p.shadowDecisions)try{gc.get(a.stateDir,r).recordRuleHostEvaluated({toolName:e.toolName,filePath:c,matched:g.matched,decision:g.decision,ruleId:g.ruleId,activationId:g.activationId,activationMode:"shadow"})}catch(y){r?.warn?.(`[PD_GATE] Failed to record shadow rulehost_evaluated: ${String(y)}`)}try{gc.get(a.stateDir,r).recordRuleHostEvaluated({toolName:e.toolName,filePath:c,matched:m?.matched??!1,decision:m?.decision??"allow",ruleId:m?.ruleId,activationId:p.liveDecisionActivationId,activationMode:"live"})}catch(g){r?.warn?.(`[PD_GATE] Failed to record rulehost_evaluated: ${String(g)}`)}if(m?.decision==="block"){try{let g=gc.get(a.stateDir,r);g.recordRuleEnforced({ruleId:m.ruleId||"unknown",principleId:m.principleId||"unknown",enforcement:"block",toolName:e.toolName,filePath:c}),g.recordRuleHostBlocked({toolName:e.toolName,filePath:c,reason:m.reason,ruleId:m.ruleId})}catch(g){r?.warn?.(`[PD_GATE] Failed to record rule_enforced/rulehost_blocked: ${String(g)}`)}try{if(ei(a.workspaceDir,"principle_receipt_ledger").enabled){let g=m.principleId??m.ruleId;g&&(bke(a.workspaceDir,{principleId:g,ruleId:m.ruleId,channel:"code_tool_hook",level:"effect",kind:"rule_blocked",sessionId:t.sessionId,toolName:e.toolName,filePath:c,digest:m.reason})||r?.warn?.("[PD_GATE] Receipt ledger write failed (rule_blocked) \u2014 history degraded, block unaffected (rc-9)"))}}catch(g){r?.warn?.(`[PD_GATE] Receipt ledger write threw (rule_blocked): ${String(g)}`)}return fFt(a,{filePath:c,reason:m.reason,toolName:e.toolName,sessionId:t.sessionId,blockSource:"rule-host",ruleId:m.ruleId,principleId:m.principleId},r)}if(m?.decision==="requireApproval")try{let g=gc.get(a.stateDir,r);g.recordRuleEnforced({ruleId:m.ruleId||"unknown",principleId:m.principleId||"unknown",enforcement:"requireApproval",toolName:e.toolName,filePath:c}),g.recordRuleHostRequireApproval({toolName:e.toolName,filePath:c,reason:m.reason,ruleId:m.ruleId})}catch(g){r?.warn?.(`[PD_GATE] Failed to record rule_enforced/rulehost_requireApproval: ${String(g)}`)}if(m?.decision==="auto_correct"&&m.correctionProposal){let g=m.correctionProposal,y;try{y=ff(g)}catch(S){y={valid:!1,errors:[`Validator threw: ${String(S)}`]}}try{let S=gc.get(a.stateDir,r),b=Array.isArray(g.correctedFields)?g.correctedFields.map(w=>String(typeof w=="object"&&w!==null?w.field:w)):[];S.recordRuleHostAutoCorrectProposed({toolName:e.toolName,filePath:c,ruleId:String(g.ruleId??"unknown"),principleId:g.principleId!=null?String(g.principleId):void 0,confidence:typeof g.confidence=="number"?g.confidence:0,reason:m.reason,applicationMode:g.applicationMode==="live"?"live":"shadow",correctedFields:b,validationValid:y.valid})}catch(S){r?.warn?.(`[PD_GATE] Failed to record rulehost_auto_correct_proposed: ${String(S)}`)}if(g.applicationMode==="live"&&y.valid){if(!e.params)return;let S={...e.params},b={},w=[];try{if(!Array.isArray(g.correctedFields))throw new Error("proposal.correctedFields is not an array");if(!g.proposedParams||typeof g.proposedParams!="object"||Array.isArray(g.proposedParams))throw new Error("proposal.proposedParams must be an object");let D=t.workspaceDir;if(typeof D=="string"&&D.trim().length>0){let q=GTe(g.proposedParams,D);if(!q.valid)throw new Error(`Path boundary violation: ${q.reason}`)}else if(Object.keys(g.proposedParams).some(W=>typeof g.proposedParams[W]=="string"&&(W==="file_path"||W==="path"||W==="filePath")))throw new Error("Cannot apply live auto-correction with path fields: no trusted workspace directory available");for(let q of g.correctedFields){if(typeof q!="object"||q===null||typeof q.field!="string")throw new Error("correctedFields entry must be an object with a string field");let W=q.field;if(!Object.hasOwn(e.params,W))throw new Error(`Field '${W}' not found in event.params`);if(!Object.hasOwn(g.proposedParams,W))throw new Error(`Field '${W}' not found in proposal.proposedParams`)}for(let q of g.correctedFields)if(typeof q=="object"&&q!==null&&typeof q.field=="string"){let W=q.field,ne=e.params[W],se=g.proposedParams[W];b[W]=se,w.push({field:W,original:ne,applied:se})}Object.assign(e.params,b);try{gc.get(a.stateDir,r).recordRuleHostAutoCorrectApplied({toolName:e.toolName,filePath:c,ruleId:String(g.ruleId??"unknown"),principleId:g.principleId!=null?String(g.principleId):void 0,confidence:typeof g.confidence=="number"?g.confidence:0,reason:m.reason||g.correctedFields?.[0]?.reason||"auto-correct applied",correctedFields:w})}catch(q){r?.warn?.(`[PD_GATE] Failed to record rulehost_auto_correct_applied: ${String(q)}`)}if(w.length>0){try{if(a2t(t.sessionId,a.workspaceDir),ei(a.workspaceDir,"principle_receipt_ledger").enabled){let q=g.principleId!=null?String(g.principleId):String(g.ruleId??"unknown");bke(a.workspaceDir,{principleId:q,ruleId:String(g.ruleId??"unknown"),channel:"code_tool_hook",level:"effect",kind:"auto_correct_applied",sessionId:t.sessionId,toolName:e.toolName,filePath:c,digest:w.map(ne=>`${ne.field}: ${JSON.stringify(ne.original)} -> ${JSON.stringify(ne.applied)}`).join(", ").slice(0,200)})||r?.warn?.("[PD_GATE] Receipt ledger write failed (auto_correct_applied) \u2014 history degraded, correction unaffected (rc-9)")}}catch(q){r?.warn?.(`[PD_GATE] Receipt ledger write threw (auto_correct_applied): ${String(q)}`)}return{params:{...e.params}}}}catch(D){e.params&&Object.assign(e.params,S);let q=String(D);if(q.includes("Path boundary violation")||q.includes("no trusted workspace directory")){r?.warn?.(`[PD_GATE] Live auto-correction rejected \u2014 path out of bounds: ${q}`);try{gc.get(a.stateDir,r).recordRuleHostAutoCorrectProposed({toolName:e.toolName,filePath:c,ruleId:String(g.ruleId??"unknown"),principleId:g.principleId!=null?String(g.principleId):void 0,confidence:typeof g.confidence=="number"?g.confidence:0,reason:`Path boundary rejected: ${q}`,applicationMode:"shadow",correctedFields:Array.isArray(g.correctedFields)?g.correctedFields.map(se=>String(typeof se=="object"&&se!==null?se.field:se)):[],validationValid:!1})}catch(ne){r?.warn?.(`[PD_GATE] Failed to record path rejection telemetry: ${String(ne)}`)}}else r?.warn?.(`[PD_GATE] Failed to apply auto-correction, using original params: ${q}`)}}}else if(m?.decision==="auto_correct")try{gc.get(a.stateDir,r).recordRuleHostAutoCorrectProposed({toolName:e.toolName,filePath:c,ruleId:m.ruleId??"unknown",confidence:0,reason:m.reason??"auto_correct without correctionProposal",applicationMode:"shadow",correctedFields:[],validationValid:!1})}catch(g){r?.warn?.(`[PD_GATE] Failed to record rulehost_auto_correct_proposed (no proposal): ${String(g)}`)}}catch(u){r.warn?.(`[PD_GATE:RULE_HOST] Host evaluation failed, allowing conservatively: ${String(u)}`)}}function _Ft(e){if(!e)return 0;try{return qc(e)?.currentGfi??0}catch{return 0}}function yFt(e){try{return nQ(e).getTier()}catch{return 0}}function SFt(e){if(!rQ.has(e.toolName))return"unknown";try{let t=String(e.params?.command||e.params?.args||"");return/\brm\s+-rf\b|\bchmod\b|\bchown\b|>\s*\/dev\//.test(t)?"dangerous":/(?:>|>>|sed|rm|mv|mkdir|touch|cp|npm|yarn|pnpm|pip|cargo)/.test(t)?"normal":"safe"}catch{return"unknown"}}function xFt(e,t,r){return{currentGfi:_Ft(r),epTier:yFt(t),bashRisk:SFt(e)}}function Gke(e,t,r,n){let o;try{o=ha(e.workspaceDir)}catch(s){n?.warn?.(`[PD_GATE] RuleContext v2: config load failed, skipping context assembly: ${String(s)}`);return}if(!o.ok){let s=o.errors.map(c=>c.reason).join("; ");n?.warn?.(`[PD_GATE] RuleContext v2: config load returned malformed result, skipping context assembly: ${s}`);return}if(li(o.effective).flags.rulecode_context_v2?.enabled)try{return gFt(r,t,e.trajectory,e.workspaceDir)}catch(s){return n?.warn?.(`[PD_GATE] RuleContext v2: buildProductionRuleContext threw unexpectedly, using unavailable context: ${String(s)}`),Vf}}function bFt(e,t,r){let n=t.logger??console;for(let d of r.warnings??[])n.warn?.(`[PD_GATE:RULE_HOST] ${d}`);let o=r.metadata?.evaluatedLiveRules;n.info?.(`[PD_GATE:RULE_HOST] shared production gate evaluated; liveRules=${typeof o=="number"?o:"unknown"} decision=${r.decision}`);let i=r.metadata,a=i?.ruleDecision;if(a==="auto_correct"||a==="requireApproval"){n.info?.(`[PD_GATE:RULE_HOST] shared result carries ruleDecision=${String(a)}; the legacy handler records the decision events`);return}let s=rr.fromHookContext(t),c=Xx(e.toolName,e.params??{},s.workspaceDir,{isBashTool:rQ.has(e.toolName),isWriteTool:kke.has(e.toolName)});if(c.normalizedPath===null)return;let u=typeof i?.ruleId=="string"?i.ruleId:void 0,l=typeof i?.principleId=="string"?i.principleId:void 0;try{let d=gc.get(s.stateDir,n);d.recordRuleHostEvaluated({toolName:e.toolName,filePath:c.normalizedPath,matched:r.decision==="deny",decision:r.decision==="deny"?"block":"allow",ruleId:u,activationMode:"live"}),r.decision==="deny"&&(d.recordRuleEnforced({ruleId:u??"unknown",principleId:l??"unknown",enforcement:"block",toolName:e.toolName,filePath:c.normalizedPath}),d.recordRuleHostBlocked({toolName:e.toolName,filePath:c.normalizedPath,reason:r.reason??"RuleHost denied the tool call",ruleId:u}))}catch(d){n.warn?.(`[PD_GATE] Failed to record shared RuleHost result: ${String(d)}`)}}import*as $i from"fs";import*as N0 from"path";import*as Bke from"readline";async function vFt(e,t){if(!t.workspaceDir||!e.messages||e.messages.length===0)return;let r=rr.fromHookContext(t),n=e.messages.filter(o=>{let i=o;return i.role==="assistant"&&typeof i.content=="string"&&(i.content.includes("error")||i.content.includes("fail")||i.content.includes("blocked"))});if(n.length>0){let o=r.resolve("MEMORY_MD"),i=`
|
|
2610
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`}function hFt(e,t,r,n,o){if(r>3){o(`[PD_GATE] Failed to persist trajectory gate block after ${3} retries: ${t.toolName} ${t.filePath}`);return}setTimeout(()=>{try{e.trajectory?.recordGateBlock?.(t),n(`[PD_GATE] Trajectory gate block persisted on retry ${r}`)}catch(i){n(`[PD_GATE] Retrying trajectory gate block persistence (attempt ${r+1}): ${String(i)}`),hFt(e,t,r+1,n,o)}},250*r).unref()}var vDn=new Set(["success","failure","blocked"]),TDn=20;function EDn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function RDn(e){return typeof e=="string"&&vDn.has(e)}function wDn(e,t,r){let n=[];for(let o of e){let i=o.toolName;if(typeof i!="string"||i.length===0)return lP(`row id=${o.id}: tool_name must be a non-empty string`);let a=o.outcome;if(!RDn(a))return lP(`row id=${o.id}: outcome "${o.outcome}" is not a valid RuleToolOutcome`);let s=o.paramsJson;if(typeof s!="string")return lP(`row id=${o.id}: params_json must be a string`);let c;try{c=JSON.parse(s)}catch{return lP(`row id=${o.id}: params_json is not valid JSON`)}if(!EDn(c))return lP(`row id=${o.id}: params_json must parse to a non-array object`);let u=WN(i),l=AJ(c,{isBashTool:u==="execute",isWriteTool:u==="write",toolName:i}),d=kJ(l,r);n.push({sequenceId:o.id,toolName:i,canonicalKind:u,normalizedPath:d===""?null:d,paramsSummary:c,outcome:a})}return{status:"available",truncated:t,calls:n}}function gFt(e,t,r,n,o=TDn){if(!e||typeof e!="string"||e.length===0)return Vf;try{let i=r.getRuleHostContextRows(e,o),a=wDn(i.rows,i.truncated,n),s=Ote(a,t,null);return{version:2,history:a,facts:s}}catch{return IDn("query or assembly failed")}}function lP(e){return{status:"unavailable",unavailableReason:e,truncated:!1,calls:[]}}function IDn(e){return{version:2,history:lP(e),facts:{priorReadOfTarget:"unknown",readCount:null,writeCount:null,uniqueWritePathCount:null,sameActionBlockCount:null}}}function jke(e,t){let r=t.logger||console,n=rQ.has(e.toolName),o=kke.has(e.toolName),i=V2t.has(e.toolName);if(!t.workspaceDir||!o&&!n&&!i)return;let a=rr.fromHookContext(t),s=Xx(e.toolName,e.params??{},a.workspaceDir,{isBashTool:n,isWriteTool:o}),c=s.normalizedPath;if(c!==null)try{let u=a.getRuleHost(r),l=Gke(a,c,t.sessionId,r),d={action:s,workspace:{isRiskPath:!1},session:{sessionId:t.sessionId,currentGfi:_Ft(t.sessionId)},evolution:{epTier:yFt(a.workspaceDir)},derived:{estimatedLineChanges:FO({toolName:e.toolName,params:e.params??{}}),bashRisk:SFt(e)},context:l},p=typeof u.evaluateDetailed=="function"?u.evaluateDetailed(d):{liveDecision:u.evaluate(d),shadowDecisions:[],skippedActivations:[]},m=p.liveDecision;if(jY({workspaceDir:a.workspaceDir,activationId:p.liveDecisionActivationId,toolName:e.toolName,params:e.params??{},decision:m?.decision??"allow",matched:m?.matched??!1,logger:r})){r.warn?.(`[PD_GATE] RuleCode ${p.liveDecisionActivationId??"unknown"} safety-isolated; allowing current host call.`);return}for(let g of p.shadowDecisions)try{gc.get(a.stateDir,r).recordRuleHostEvaluated({toolName:e.toolName,filePath:c,matched:g.matched,decision:g.decision,ruleId:g.ruleId,activationId:g.activationId,activationMode:"shadow"})}catch(y){r?.warn?.(`[PD_GATE] Failed to record shadow rulehost_evaluated: ${String(y)}`)}try{gc.get(a.stateDir,r).recordRuleHostEvaluated({toolName:e.toolName,filePath:c,matched:m?.matched??!1,decision:m?.decision??"allow",ruleId:m?.ruleId,activationId:p.liveDecisionActivationId,activationMode:"live"})}catch(g){r?.warn?.(`[PD_GATE] Failed to record rulehost_evaluated: ${String(g)}`)}if(m?.decision==="block"){try{let g=gc.get(a.stateDir,r);g.recordRuleEnforced({ruleId:m.ruleId||"unknown",principleId:m.principleId||"unknown",enforcement:"block",toolName:e.toolName,filePath:c}),g.recordRuleHostBlocked({toolName:e.toolName,filePath:c,reason:m.reason,ruleId:m.ruleId})}catch(g){r?.warn?.(`[PD_GATE] Failed to record rule_enforced/rulehost_blocked: ${String(g)}`)}try{if(ei(a.workspaceDir,"principle_receipt_ledger").enabled){let g=m.principleId??m.ruleId;g?bke(a.workspaceDir,{principleId:g,ruleId:m.ruleId,channel:"code_tool_hook",level:"effect",kind:"rule_blocked",sessionId:t.sessionId,toolName:e.toolName,filePath:c,digest:m.reason})||r?.warn?.("[PD_GATE] Receipt ledger write failed (rule_blocked) \u2014 history degraded, block unaffected (rc-9)"):r?.warn?.("[PD_GATE] Receipt ledger row skipped (rule_blocked): decision carries no principleId/ruleId \u2014 effect evidence not captured (rc-9)")}}catch(g){r?.warn?.(`[PD_GATE] Receipt ledger write threw (rule_blocked): ${String(g)}`)}return fFt(a,{filePath:c,reason:m.reason,toolName:e.toolName,sessionId:t.sessionId,blockSource:"rule-host",ruleId:m.ruleId,principleId:m.principleId},r)}if(m?.decision==="requireApproval")try{let g=gc.get(a.stateDir,r);g.recordRuleEnforced({ruleId:m.ruleId||"unknown",principleId:m.principleId||"unknown",enforcement:"requireApproval",toolName:e.toolName,filePath:c}),g.recordRuleHostRequireApproval({toolName:e.toolName,filePath:c,reason:m.reason,ruleId:m.ruleId})}catch(g){r?.warn?.(`[PD_GATE] Failed to record rule_enforced/rulehost_requireApproval: ${String(g)}`)}if(m?.decision==="auto_correct"&&m.correctionProposal){let g=m.correctionProposal,y;try{y=ff(g)}catch(S){y={valid:!1,errors:[`Validator threw: ${String(S)}`]}}try{let S=gc.get(a.stateDir,r),b=Array.isArray(g.correctedFields)?g.correctedFields.map(w=>String(typeof w=="object"&&w!==null?w.field:w)):[];S.recordRuleHostAutoCorrectProposed({toolName:e.toolName,filePath:c,ruleId:String(g.ruleId??"unknown"),principleId:g.principleId!=null?String(g.principleId):void 0,confidence:typeof g.confidence=="number"?g.confidence:0,reason:m.reason,applicationMode:g.applicationMode==="live"?"live":"shadow",correctedFields:b,validationValid:y.valid})}catch(S){r?.warn?.(`[PD_GATE] Failed to record rulehost_auto_correct_proposed: ${String(S)}`)}if(g.applicationMode==="live"&&y.valid){if(!e.params)return;let S={...e.params},b={},w=[];try{if(!Array.isArray(g.correctedFields))throw new Error("proposal.correctedFields is not an array");if(!g.proposedParams||typeof g.proposedParams!="object"||Array.isArray(g.proposedParams))throw new Error("proposal.proposedParams must be an object");let D=t.workspaceDir;if(typeof D=="string"&&D.trim().length>0){let q=GTe(g.proposedParams,D);if(!q.valid)throw new Error(`Path boundary violation: ${q.reason}`)}else if(Object.keys(g.proposedParams).some(W=>typeof g.proposedParams[W]=="string"&&(W==="file_path"||W==="path"||W==="filePath")))throw new Error("Cannot apply live auto-correction with path fields: no trusted workspace directory available");for(let q of g.correctedFields){if(typeof q!="object"||q===null||typeof q.field!="string")throw new Error("correctedFields entry must be an object with a string field");let W=q.field;if(!Object.hasOwn(e.params,W))throw new Error(`Field '${W}' not found in event.params`);if(!Object.hasOwn(g.proposedParams,W))throw new Error(`Field '${W}' not found in proposal.proposedParams`)}for(let q of g.correctedFields)if(typeof q=="object"&&q!==null&&typeof q.field=="string"){let W=q.field,ne=e.params[W],se=g.proposedParams[W];b[W]=se,w.push({field:W,original:ne,applied:se})}Object.assign(e.params,b);try{gc.get(a.stateDir,r).recordRuleHostAutoCorrectApplied({toolName:e.toolName,filePath:c,ruleId:String(g.ruleId??"unknown"),principleId:g.principleId!=null?String(g.principleId):void 0,confidence:typeof g.confidence=="number"?g.confidence:0,reason:m.reason||g.correctedFields?.[0]?.reason||"auto-correct applied",correctedFields:w})}catch(q){r?.warn?.(`[PD_GATE] Failed to record rulehost_auto_correct_applied: ${String(q)}`)}if(w.length>0){try{if(a2t(t.sessionId,a.workspaceDir),ei(a.workspaceDir,"principle_receipt_ledger").enabled){let q=g.principleId!=null?String(g.principleId):String(g.ruleId??"unknown");bke(a.workspaceDir,{principleId:q,ruleId:String(g.ruleId??"unknown"),channel:"code_tool_hook",level:"effect",kind:"auto_correct_applied",sessionId:t.sessionId,toolName:e.toolName,filePath:c,digest:w.map(ne=>`${ne.field}: ${JSON.stringify(ne.original)} -> ${JSON.stringify(ne.applied)}`).join(", ").slice(0,200)})||r?.warn?.("[PD_GATE] Receipt ledger write failed (auto_correct_applied) \u2014 history degraded, correction unaffected (rc-9)")}}catch(q){r?.warn?.(`[PD_GATE] Receipt ledger write threw (auto_correct_applied): ${String(q)}`)}return{params:{...e.params}}}}catch(D){e.params&&Object.assign(e.params,S);let q=String(D);if(q.includes("Path boundary violation")||q.includes("no trusted workspace directory")){r?.warn?.(`[PD_GATE] Live auto-correction rejected \u2014 path out of bounds: ${q}`);try{gc.get(a.stateDir,r).recordRuleHostAutoCorrectProposed({toolName:e.toolName,filePath:c,ruleId:String(g.ruleId??"unknown"),principleId:g.principleId!=null?String(g.principleId):void 0,confidence:typeof g.confidence=="number"?g.confidence:0,reason:`Path boundary rejected: ${q}`,applicationMode:"shadow",correctedFields:Array.isArray(g.correctedFields)?g.correctedFields.map(se=>String(typeof se=="object"&&se!==null?se.field:se)):[],validationValid:!1})}catch(ne){r?.warn?.(`[PD_GATE] Failed to record path rejection telemetry: ${String(ne)}`)}}else r?.warn?.(`[PD_GATE] Failed to apply auto-correction, using original params: ${q}`)}}}else if(m?.decision==="auto_correct")try{gc.get(a.stateDir,r).recordRuleHostAutoCorrectProposed({toolName:e.toolName,filePath:c,ruleId:m.ruleId??"unknown",confidence:0,reason:m.reason??"auto_correct without correctionProposal",applicationMode:"shadow",correctedFields:[],validationValid:!1})}catch(g){r?.warn?.(`[PD_GATE] Failed to record rulehost_auto_correct_proposed (no proposal): ${String(g)}`)}}catch(u){r.warn?.(`[PD_GATE:RULE_HOST] Host evaluation failed, allowing conservatively: ${String(u)}`)}}function _Ft(e){if(!e)return 0;try{return qc(e)?.currentGfi??0}catch{return 0}}function yFt(e){try{return nQ(e).getTier()}catch{return 0}}function SFt(e){if(!rQ.has(e.toolName))return"unknown";try{let t=String(e.params?.command||e.params?.args||"");return/\brm\s+-rf\b|\bchmod\b|\bchown\b|>\s*\/dev\//.test(t)?"dangerous":/(?:>|>>|sed|rm|mv|mkdir|touch|cp|npm|yarn|pnpm|pip|cargo)/.test(t)?"normal":"safe"}catch{return"unknown"}}function xFt(e,t,r){return{currentGfi:_Ft(r),epTier:yFt(t),bashRisk:SFt(e)}}function Gke(e,t,r,n){let o;try{o=ha(e.workspaceDir)}catch(s){n?.warn?.(`[PD_GATE] RuleContext v2: config load failed, skipping context assembly: ${String(s)}`);return}if(!o.ok){let s=o.errors.map(c=>c.reason).join("; ");n?.warn?.(`[PD_GATE] RuleContext v2: config load returned malformed result, skipping context assembly: ${s}`);return}if(li(o.effective).flags.rulecode_context_v2?.enabled)try{return gFt(r,t,e.trajectory,e.workspaceDir)}catch(s){return n?.warn?.(`[PD_GATE] RuleContext v2: buildProductionRuleContext threw unexpectedly, using unavailable context: ${String(s)}`),Vf}}function bFt(e,t,r){let n=t.logger??console;for(let d of r.warnings??[])n.warn?.(`[PD_GATE:RULE_HOST] ${d}`);let o=r.metadata?.evaluatedLiveRules;n.info?.(`[PD_GATE:RULE_HOST] shared production gate evaluated; liveRules=${typeof o=="number"?o:"unknown"} decision=${r.decision}`);let i=r.metadata,a=i?.ruleDecision;if(a==="auto_correct"||a==="requireApproval"){n.info?.(`[PD_GATE:RULE_HOST] shared result carries ruleDecision=${String(a)}; the legacy handler records the decision events`);return}let s=rr.fromHookContext(t),c=Xx(e.toolName,e.params??{},s.workspaceDir,{isBashTool:rQ.has(e.toolName),isWriteTool:kke.has(e.toolName)});if(c.normalizedPath===null)return;let u=typeof i?.ruleId=="string"?i.ruleId:void 0,l=typeof i?.principleId=="string"?i.principleId:void 0;try{let d=gc.get(s.stateDir,n);d.recordRuleHostEvaluated({toolName:e.toolName,filePath:c.normalizedPath,matched:r.decision==="deny",decision:r.decision==="deny"?"block":"allow",ruleId:u,activationMode:"live"}),r.decision==="deny"&&(d.recordRuleEnforced({ruleId:u??"unknown",principleId:l??"unknown",enforcement:"block",toolName:e.toolName,filePath:c.normalizedPath}),d.recordRuleHostBlocked({toolName:e.toolName,filePath:c.normalizedPath,reason:r.reason??"RuleHost denied the tool call",ruleId:u}))}catch(d){n.warn?.(`[PD_GATE] Failed to record shared RuleHost result: ${String(d)}`)}}import*as $i from"fs";import*as N0 from"path";import*as Bke from"readline";async function vFt(e,t){if(!t.workspaceDir||!e.messages||e.messages.length===0)return;let r=rr.fromHookContext(t),n=e.messages.filter(o=>{let i=o;return i.role==="assistant"&&typeof i.content=="string"&&(i.content.includes("error")||i.content.includes("fail")||i.content.includes("blocked"))});if(n.length>0){let o=r.resolve("MEMORY_MD"),i=`
|
|
2611
2611
|
## [${new Date().toISOString()}] Session Reset Summary (Reason: ${e.reason??"Manual"})
|
|
2612
2612
|
- Encountered ${n.length} potential pain point(s) during this session.
|
|
2613
2613
|
- Action: These are informational notes only; Runtime V2 hooks capture pain evidence automatically. Review via pd-console (\`pd console open\`) if you want them turned into principle candidates.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.219.0",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onCapabilities": [
|
|
8
8
|
"hook"
|
package/plugin/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "principles-disciple",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.219.0",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|