snipara-companion 2.0.2 → 2.0.3

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/dist/index.d.ts CHANGED
@@ -541,6 +541,41 @@ interface EmitEventResult {
541
541
  sessionIds: string[];
542
542
  events: AutomationCheckpointSummary[];
543
543
  }
544
+ type AdvisorInfluenceAgentDecision = "accepted" | "modified" | "ignored" | "blocked";
545
+ type AdvisorInfluenceOutcomeLinkStatus = "pending" | "linked" | "missed" | "unevaluated";
546
+ interface AdvisorInfluenceRecommendationInput {
547
+ id: string;
548
+ version?: "advisor-recommendation-v0";
549
+ source: string;
550
+ severity: string;
551
+ title: string;
552
+ rationale: string;
553
+ reasonCodes: string[];
554
+ historicalImpactSummary?: string | null;
555
+ reasonCodeReliability?: number | null;
556
+ recommendedVerification: string[];
557
+ expectedBehaviorChange: string;
558
+ evidence?: unknown[];
559
+ caveats?: string[];
560
+ }
561
+ interface RecordAdvisorInfluenceReceiptInput {
562
+ servedJudgmentId: string;
563
+ recommendation: AdvisorInfluenceRecommendationInput;
564
+ agentDecision: AdvisorInfluenceAgentDecision;
565
+ behaviorChange: string;
566
+ verificationExecuted: string[];
567
+ outcomeLinkStatus?: AdvisorInfluenceOutcomeLinkStatus;
568
+ metadata?: Record<string, unknown>;
569
+ }
570
+ interface RecordAdvisorInfluenceReceiptResult {
571
+ project: {
572
+ id: string;
573
+ name: string;
574
+ slug: string;
575
+ };
576
+ receipt: Record<string, unknown>;
577
+ advisorInfluence: Record<string, unknown>;
578
+ }
544
579
  interface AutomationConfigFile {
545
580
  path: string;
546
581
  content: string;
@@ -1179,6 +1214,7 @@ declare class RLMClient {
1179
1214
  privacy_level: "standard" | "sensitive" | "restricted";
1180
1215
  payload?: Record<string, unknown>;
1181
1216
  }): Promise<EmitEventResult>;
1217
+ recordAdvisorInfluenceReceipt(input: RecordAdvisorInfluenceReceiptInput): Promise<RecordAdvisorInfluenceReceiptResult>;
1182
1218
  getAutomationEvents(args?: {
1183
1219
  sessionId?: string;
1184
1220
  limit?: number;
@@ -2004,6 +2040,8 @@ interface ProjectRunCommandOptions {
2004
2040
  skipMemoryHealth?: boolean;
2005
2041
  skipGuard?: boolean;
2006
2042
  skipPackageReview?: boolean;
2043
+ servedJudgmentId?: string;
2044
+ skipAdvisorReceipts?: boolean;
2007
2045
  json?: boolean;
2008
2046
  }
2009
2047
  interface ProjectRunGuardResult {
@@ -2021,6 +2059,20 @@ interface ProjectRunPackageReview {
2021
2059
  data?: unknown;
2022
2060
  error?: string;
2023
2061
  }
2062
+ interface ProjectRunAdvisorReceiptWrite {
2063
+ advisorRecommendationId: string;
2064
+ status: "recorded" | "error";
2065
+ result?: RecordAdvisorInfluenceReceiptResult;
2066
+ error?: string;
2067
+ }
2068
+ interface ProjectRunAdvisorReceiptCapture {
2069
+ status: "skipped" | "recorded" | "partial" | "error";
2070
+ servedJudgmentId?: string;
2071
+ attemptedCount: number;
2072
+ recordedCount: number;
2073
+ writes: ProjectRunAdvisorReceiptWrite[];
2074
+ reason?: string;
2075
+ }
2024
2076
  interface ProjectIntelligenceRunResult {
2025
2077
  version: "project-intelligence.production-run.v1";
2026
2078
  generatedAt: string;
@@ -2028,6 +2080,7 @@ interface ProjectIntelligenceRunResult {
2028
2080
  brief: ProjectIntelligenceBrief;
2029
2081
  guard?: ProjectRunGuardResult;
2030
2082
  packageReview?: ProjectRunPackageReview;
2083
+ advisorReceiptCapture?: ProjectRunAdvisorReceiptCapture;
2031
2084
  judgmentCard: ProjectIntelligenceJudgmentCard;
2032
2085
  suggestedCommands: string[];
2033
2086
  }
package/dist/index.js CHANGED
@@ -953,6 +953,19 @@ var RLMClient = class {
953
953
  clearTimeout(timeoutId);
954
954
  }
955
955
  }
956
+ async recordAdvisorInfluenceReceipt(input) {
957
+ return this.dashboardProjectRequest(
958
+ "/project-intelligence/advisor-influence",
959
+ {
960
+ method: "POST",
961
+ body: input
962
+ },
963
+ {
964
+ invalidMessage: "Advisor influence receipt write failed",
965
+ validate: (data) => Boolean(data.receipt && data.advisorInfluence)
966
+ }
967
+ );
968
+ }
956
969
  async getAutomationEvents(args) {
957
970
  if (!this.config.apiKey) {
958
971
  throw new Error("API key not configured. Run 'npx -y snipara-companion@latest init' first.");
@@ -11563,6 +11576,158 @@ function outputPreview(value) {
11563
11576
  return `${value.slice(0, RAW_OUTPUT_PREVIEW_BYTES)}
11564
11577
  ...[truncated]`;
11565
11578
  }
11579
+ function stringValue4(value) {
11580
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
11581
+ }
11582
+ function servedJudgmentIdFromUnknown(value, depth = 0) {
11583
+ if (depth > 5 || value === null || value === void 0) {
11584
+ return void 0;
11585
+ }
11586
+ if (!isRecord7(value)) {
11587
+ if (Array.isArray(value)) {
11588
+ for (const item of value.slice(0, 12)) {
11589
+ const found = servedJudgmentIdFromUnknown(item, depth + 1);
11590
+ if (found) return found;
11591
+ }
11592
+ }
11593
+ return void 0;
11594
+ }
11595
+ const direct = stringValue4(value.servedJudgmentId) ?? stringValue4(value.served_judgment_id);
11596
+ if (direct) {
11597
+ return direct;
11598
+ }
11599
+ for (const key of [
11600
+ "projectIntelligence",
11601
+ "project_intelligence",
11602
+ "brief",
11603
+ "judgment",
11604
+ "resumeContext",
11605
+ "resume_context",
11606
+ "data"
11607
+ ]) {
11608
+ const found = servedJudgmentIdFromUnknown(value[key], depth + 1);
11609
+ if (found) return found;
11610
+ }
11611
+ return void 0;
11612
+ }
11613
+ function servedJudgmentIdForRun(options, brief) {
11614
+ return stringValue4(options.servedJudgmentId) ?? servedJudgmentIdFromUnknown(brief.resumeContext) ?? servedJudgmentIdFromUnknown(brief.verificationPlan);
11615
+ }
11616
+ function normalizeAdvisorSource(value) {
11617
+ if (value === "judgment" || value === "outcome_calibration" || value === "historical_impact" || value === "safety" || value === "verification" || value === "context_quality") {
11618
+ return value;
11619
+ }
11620
+ return "judgment";
11621
+ }
11622
+ function normalizeAdvisorSeverity2(value) {
11623
+ if (value === "info" || value === "watch" || value === "risk" || value === "block") {
11624
+ return value;
11625
+ }
11626
+ return "watch";
11627
+ }
11628
+ function advisorReceiptRecommendation(recommendation) {
11629
+ return {
11630
+ id: recommendation.id,
11631
+ version: "advisor-recommendation-v0",
11632
+ source: normalizeAdvisorSource(recommendation.source),
11633
+ severity: normalizeAdvisorSeverity2(recommendation.severity),
11634
+ title: recommendation.title,
11635
+ rationale: recommendation.rationale ?? recommendation.expectedBehaviorChange ?? `Snipara recommended ${recommendation.title}.`,
11636
+ reasonCodes: recommendation.reasonCodes,
11637
+ historicalImpactSummary: recommendation.historicalImpactSummary ?? null,
11638
+ reasonCodeReliability: recommendation.reasonCodeReliability ?? null,
11639
+ recommendedVerification: recommendation.recommendedVerification,
11640
+ expectedBehaviorChange: recommendation.expectedBehaviorChange ?? `Adapt the visible plan according to ${recommendation.title}.`,
11641
+ evidence: [],
11642
+ caveats: ["First-party companion receipt records plan adaptation, not outcome proof."]
11643
+ };
11644
+ }
11645
+ function advisorReceiptDecision(recommendation, judgmentCard) {
11646
+ if (recommendation.severity === "block" && judgmentCard.canProceed === "block") {
11647
+ return "blocked";
11648
+ }
11649
+ return "modified";
11650
+ }
11651
+ function advisorReceiptBehaviorChange(recommendation, judgmentCard) {
11652
+ const verification = recommendation.recommendedVerification.slice(0, 3).join("; ");
11653
+ const mode = recommendation.severity === "block" || recommendation.severity === "risk" ? "required action" : "advisory action";
11654
+ return [
11655
+ `snipara-companion run added a ${mode} from Project Advisor: ${recommendation.title}.`,
11656
+ recommendation.expectedBehaviorChange ? `Expected adaptation: ${recommendation.expectedBehaviorChange}.` : null,
11657
+ verification ? `Recommended verification to perform: ${verification}.` : null,
11658
+ `Judgment state after adaptation: ${judgmentCard.state}.`
11659
+ ].filter(Boolean).join(" ");
11660
+ }
11661
+ async function recordFirstPartyAdvisorReceipts(args) {
11662
+ if (args.options.skipAdvisorReceipts) {
11663
+ return {
11664
+ status: "skipped",
11665
+ attemptedCount: 0,
11666
+ recordedCount: 0,
11667
+ writes: [],
11668
+ reason: "advisor receipt capture was explicitly skipped"
11669
+ };
11670
+ }
11671
+ if (args.judgmentCard.advisorRecommendations.length === 0) {
11672
+ return void 0;
11673
+ }
11674
+ const servedJudgmentId = servedJudgmentIdForRun(args.options, args.brief);
11675
+ if (!servedJudgmentId) {
11676
+ return {
11677
+ status: "skipped",
11678
+ attemptedCount: 0,
11679
+ recordedCount: 0,
11680
+ writes: [],
11681
+ reason: "no served judgment id was available for first-party advisor receipts"
11682
+ };
11683
+ }
11684
+ const client = createClient(1e4);
11685
+ const recommendations = args.judgmentCard.advisorRecommendations.slice(0, 6);
11686
+ const writes = await Promise.all(
11687
+ recommendations.map(async (recommendation) => {
11688
+ try {
11689
+ const result = await client.recordAdvisorInfluenceReceipt({
11690
+ servedJudgmentId,
11691
+ recommendation: advisorReceiptRecommendation(recommendation),
11692
+ agentDecision: advisorReceiptDecision(recommendation, args.judgmentCard),
11693
+ behaviorChange: advisorReceiptBehaviorChange(recommendation, args.judgmentCard),
11694
+ verificationExecuted: [],
11695
+ outcomeLinkStatus: "pending",
11696
+ metadata: {
11697
+ source: "snipara-companion:run",
11698
+ firstParty: true,
11699
+ runVersion: "project-intelligence.production-run.v1",
11700
+ generatedAt: args.judgmentCard.generatedAt,
11701
+ release: Boolean(args.options.release),
11702
+ branch: args.brief.branch ?? args.options.branch ?? null,
11703
+ changedFiles: args.brief.changedFiles,
11704
+ judgmentState: args.judgmentCard.state,
11705
+ canProceed: args.judgmentCard.canProceed
11706
+ }
11707
+ });
11708
+ return {
11709
+ advisorRecommendationId: recommendation.id,
11710
+ status: "recorded",
11711
+ result
11712
+ };
11713
+ } catch (error) {
11714
+ return {
11715
+ advisorRecommendationId: recommendation.id,
11716
+ status: "error",
11717
+ error: error instanceof Error ? error.message : String(error)
11718
+ };
11719
+ }
11720
+ })
11721
+ );
11722
+ const recordedCount = writes.filter((write) => write.status === "recorded").length;
11723
+ return {
11724
+ status: recordedCount === writes.length ? "recorded" : recordedCount > 0 ? "partial" : "error",
11725
+ servedJudgmentId,
11726
+ attemptedCount: writes.length,
11727
+ recordedCount,
11728
+ writes
11729
+ };
11730
+ }
11566
11731
  function runGuard(options, changedFiles) {
11567
11732
  const cliPath = process.argv[1] || "snipara-companion";
11568
11733
  const args = [
@@ -11678,6 +11843,11 @@ async function buildProjectIntelligenceRun(options) {
11678
11843
  packageReview,
11679
11844
  errors: runErrors
11680
11845
  });
11846
+ const advisorReceiptCapture = await recordFirstPartyAdvisorReceipts({
11847
+ options,
11848
+ brief,
11849
+ judgmentCard
11850
+ });
11681
11851
  const suggestedCommands = [
11682
11852
  ...brief.suggestedCommands,
11683
11853
  ...options.release ? [
@@ -11692,6 +11862,7 @@ async function buildProjectIntelligenceRun(options) {
11692
11862
  brief,
11693
11863
  ...guard ? { guard } : {},
11694
11864
  ...packageReview ? { packageReview } : {},
11865
+ ...advisorReceiptCapture ? { advisorReceiptCapture } : {},
11695
11866
  judgmentCard,
11696
11867
  suggestedCommands: [...new Set(suggestedCommands)]
11697
11868
  };
@@ -11732,6 +11903,20 @@ async function projectIntelligenceRunCommand(options) {
11732
11903
  }
11733
11904
  console.log("");
11734
11905
  }
11906
+ if (result.advisorReceiptCapture) {
11907
+ console.log(import_chalk8.default.bold("Advisor Receipts"));
11908
+ console.log(`Status: ${result.advisorReceiptCapture.status}`);
11909
+ if (result.advisorReceiptCapture.servedJudgmentId) {
11910
+ console.log(`Served judgment: ${result.advisorReceiptCapture.servedJudgmentId}`);
11911
+ }
11912
+ console.log(
11913
+ `Recorded: ${result.advisorReceiptCapture.recordedCount}/${result.advisorReceiptCapture.attemptedCount}`
11914
+ );
11915
+ if (result.advisorReceiptCapture.reason) {
11916
+ console.log(result.advisorReceiptCapture.reason);
11917
+ }
11918
+ console.log("");
11919
+ }
11735
11920
  console.log(import_chalk8.default.bold("Suggested Commands"));
11736
11921
  for (const command of result.suggestedCommands.slice(0, 8)) {
11737
11922
  console.log(command);
@@ -12002,7 +12187,7 @@ function inferAdaptiveEvidenceRequirements(query, risk) {
12002
12187
  function normalizeEndpointTypes(values) {
12003
12188
  return Array.from(
12004
12189
  new Set(
12005
- (values ?? []).map((value) => stringValue4(value)?.toLowerCase()).filter((value) => Boolean(value))
12190
+ (values ?? []).map((value) => stringValue5(value)?.toLowerCase()).filter((value) => Boolean(value))
12006
12191
  )
12007
12192
  ).sort();
12008
12193
  }
@@ -12038,24 +12223,24 @@ function readWorkflowState(rootDir) {
12038
12223
  const runtimeBindings = Array.isArray(parsed.runtime?.sandbox?.bindings) ? parsed.runtime?.sandbox?.bindings.filter(isRecord8) : [];
12039
12224
  const runtimeSandboxPhases = phases.filter((phase) => phase.needsRuntime).map((phase) => {
12040
12225
  const binding = runtimeBindings.find(
12041
- (candidate) => stringValue4(candidate.phaseId) === phase.id
12226
+ (candidate) => stringValue5(candidate.phaseId) === phase.id
12042
12227
  );
12043
12228
  const checkpoint = isRecord8(binding?.lastCheckpoint) ? binding.lastCheckpoint : void 0;
12044
12229
  return {
12045
12230
  phaseId: phase.id,
12046
12231
  title: phase.title,
12047
- bootstrapQuery: stringValue4(binding?.bootstrapQuery) ?? phase.query,
12232
+ bootstrapQuery: stringValue5(binding?.bootstrapQuery) ?? phase.query,
12048
12233
  files: phase.files,
12049
12234
  artifacts: normalizeStringList3(
12050
12235
  Array.isArray(binding?.artifacts) ? binding.artifacts : Array.isArray(checkpoint?.artifacts) ? checkpoint.artifacts : void 0
12051
12236
  ),
12052
12237
  contextPacks: normalizeContextPackIds(checkpoint?.contextPackReceipts),
12053
- sessionId: stringValue4(binding?.sessionId) ?? null,
12054
- environment: stringValue4(binding?.environment) ?? stringValue4(checkpoint?.environment) ?? null,
12055
- profile: stringValue4(binding?.profile) ?? stringValue4(checkpoint?.profile) ?? null,
12238
+ sessionId: stringValue5(binding?.sessionId) ?? null,
12239
+ environment: stringValue5(binding?.environment) ?? stringValue5(checkpoint?.environment) ?? null,
12240
+ profile: stringValue5(binding?.profile) ?? stringValue5(checkpoint?.profile) ?? null,
12056
12241
  hasCheckpoint: Boolean(checkpoint),
12057
- checkpointSummary: stringValue4(checkpoint?.summary) ?? null,
12058
- checkpointCapturedAt: stringValue4(checkpoint?.capturedAt) ?? null
12242
+ checkpointSummary: stringValue5(checkpoint?.summary) ?? null,
12243
+ checkpointCapturedAt: stringValue5(checkpoint?.capturedAt) ?? null
12059
12244
  };
12060
12245
  });
12061
12246
  return {
@@ -12071,18 +12256,18 @@ function normalizeContextPackIds(value) {
12071
12256
  return [];
12072
12257
  }
12073
12258
  return normalizeStringList3(
12074
- value.filter(isRecord8).map((receipt) => stringValue4(receipt.pack_id)).filter((packId) => Boolean(packId))
12259
+ value.filter(isRecord8).map((receipt) => stringValue5(receipt.pack_id)).filter((packId) => Boolean(packId))
12075
12260
  );
12076
12261
  }
12077
12262
  function normalizeWorkflowPhase(phase, index) {
12078
- const id = stringValue4(phase.id) ?? `phase-${index + 1}`;
12079
- const title = stringValue4(phase.title) ?? id;
12263
+ const id = stringValue5(phase.id) ?? `phase-${index + 1}`;
12264
+ const title = stringValue5(phase.title) ?? id;
12080
12265
  return {
12081
12266
  id,
12082
12267
  title,
12083
- query: stringValue4(phase.query) ?? title,
12084
- status: stringValue4(phase.status) ?? "pending",
12085
- ...stringValue4(phase.acceptance) ? { acceptance: stringValue4(phase.acceptance) } : {},
12268
+ query: stringValue5(phase.query) ?? title,
12269
+ status: stringValue5(phase.status) ?? "pending",
12270
+ ...stringValue5(phase.acceptance) ? { acceptance: stringValue5(phase.acceptance) } : {},
12086
12271
  files: normalizeStringList3(Array.isArray(phase.files) ? phase.files : void 0),
12087
12272
  gates: normalizeStringList3(Array.isArray(phase.gates) ? phase.gates : void 0),
12088
12273
  needsRuntime: Boolean(phase.needsRuntime)
@@ -12091,7 +12276,7 @@ function normalizeWorkflowPhase(phase, index) {
12091
12276
  function isRecord8(value) {
12092
12277
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
12093
12278
  }
12094
- function stringValue4(value) {
12279
+ function stringValue5(value) {
12095
12280
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
12096
12281
  }
12097
12282
  function readGitValue(rootDir, args) {
@@ -12108,7 +12293,7 @@ function readGitValue(rootDir, args) {
12108
12293
  function normalizeStringList3(values) {
12109
12294
  return Array.from(
12110
12295
  new Set(
12111
- (values ?? []).map((value) => stringValue4(value)).filter((value) => Boolean(value))
12296
+ (values ?? []).map((value) => stringValue5(value)).filter((value) => Boolean(value))
12112
12297
  )
12113
12298
  ).sort();
12114
12299
  }
@@ -15306,7 +15491,7 @@ function printKeyValue(label, value) {
15306
15491
  function isRecord9(value) {
15307
15492
  return typeof value === "object" && value !== null && !Array.isArray(value);
15308
15493
  }
15309
- function stringValue5(value) {
15494
+ function stringValue6(value) {
15310
15495
  if (value === null || value === void 0) {
15311
15496
  return void 0;
15312
15497
  }
@@ -15317,7 +15502,7 @@ function numberValue5(value) {
15317
15502
  if (typeof value === "number" && Number.isFinite(value)) {
15318
15503
  return value;
15319
15504
  }
15320
- const text = stringValue5(value);
15505
+ const text = stringValue6(value);
15321
15506
  if (!text) {
15322
15507
  return void 0;
15323
15508
  }
@@ -15328,10 +15513,10 @@ function uniqueStrings5(values) {
15328
15513
  return Array.from(new Set(values.filter((value) => value.trim().length > 0)));
15329
15514
  }
15330
15515
  function normalizeEnum(value) {
15331
- return stringValue5(value)?.replace(/[-\s]/g, "_").toUpperCase() ?? "";
15516
+ return stringValue6(value)?.replace(/[-\s]/g, "_").toUpperCase() ?? "";
15332
15517
  }
15333
15518
  function parseIsoDate(value) {
15334
- const text = stringValue5(value);
15519
+ const text = stringValue6(value);
15335
15520
  if (!text) {
15336
15521
  return void 0;
15337
15522
  }
@@ -15421,7 +15606,7 @@ function normalizeDocumentKind(value) {
15421
15606
  return void 0;
15422
15607
  }
15423
15608
  function normalizeDocumentFormat(value) {
15424
- return stringValue5(value)?.toLowerCase();
15609
+ return stringValue6(value)?.toLowerCase();
15425
15610
  }
15426
15611
  function isSupportedDocumentFormat(kind, format) {
15427
15612
  if (!kind || !format) {
@@ -15668,7 +15853,7 @@ function collectPlanFileHints(plan) {
15668
15853
  function buildPlanRelevanceWarnings(plan, options) {
15669
15854
  const warnings = [];
15670
15855
  const fileHints = collectPlanFileHints(plan);
15671
- const query = compactWhitespace(options.query ?? stringValue5(plan.query) ?? "");
15856
+ const query = compactWhitespace(options.query ?? stringValue6(plan.query) ?? "");
15672
15857
  if (fileHints.length === 0 || query.length === 0) {
15673
15858
  return warnings;
15674
15859
  }
@@ -15732,19 +15917,19 @@ function validatePlanResult(plan, options = {}) {
15732
15917
  issues.push(`Step ${index + 1} is not an object or string.`);
15733
15918
  return;
15734
15919
  }
15735
- const action = stringValue5(step.action);
15920
+ const action = stringValue6(step.action);
15736
15921
  if (action) {
15737
15922
  actions.push(action);
15738
15923
  if (isPlaceholderPlanLabel(action, index)) {
15739
15924
  issues.push(`Step ${index + 1} has a placeholder action.`);
15740
15925
  }
15741
15926
  }
15742
- const labelSource = stringValue5(step.title) ?? stringValue5(step.name) ?? action ?? stringValue5(step.goal) ?? stringValue5(step.query) ?? stringValue5(step.description);
15927
+ const labelSource = stringValue6(step.title) ?? stringValue6(step.name) ?? action ?? stringValue6(step.goal) ?? stringValue6(step.query) ?? stringValue6(step.description);
15743
15928
  if (!labelSource || isPlaceholderPlanLabel(labelSource, index)) {
15744
15929
  issues.push(`Step ${index + 1} is missing a useful title or action.`);
15745
15930
  }
15746
- const expectedOutput = stringValue5(step.expected_output);
15747
- if (!expectedOutput && !stringValue5(step.acceptance) && !stringValue5(step.verify)) {
15931
+ const expectedOutput = stringValue6(step.expected_output);
15932
+ if (!expectedOutput && !stringValue6(step.acceptance) && !stringValue6(step.verify)) {
15748
15933
  issues.push(`Step ${index + 1} is missing expected output or acceptance criteria.`);
15749
15934
  }
15750
15935
  const params = isRecord9(step.params) ? step.params : void 0;
@@ -15763,7 +15948,7 @@ function validatePlanResult(plan, options = {}) {
15763
15948
  warnings,
15764
15949
  stepCount: steps.length,
15765
15950
  actions,
15766
- ...stringValue5(plan.plan_id) ? { planId: stringValue5(plan.plan_id) } : {}
15951
+ ...stringValue6(plan.plan_id) ? { planId: stringValue6(plan.plan_id) } : {}
15767
15952
  };
15768
15953
  }
15769
15954
  function readBootstrapEntryText(entry) {
@@ -15832,7 +16017,7 @@ function normalizeStringArray3(value) {
15832
16017
  if (!raw) {
15833
16018
  return void 0;
15834
16019
  }
15835
- const items = raw.map((item) => stringValue5(item)).filter((item) => Boolean(item));
16020
+ const items = raw.map((item) => stringValue6(item)).filter((item) => Boolean(item));
15836
16021
  return items.length > 0 ? items : void 0;
15837
16022
  }
15838
16023
  function isUsableGeneratedStepQuery(value) {
@@ -15853,12 +16038,12 @@ function planStepToWorkflowStep(step, index, fallbackGoal) {
15853
16038
  };
15854
16039
  }
15855
16040
  const params = isRecord9(step.params) ? step.params : void 0;
15856
- const query = stringValue5(step.query) ?? stringValue5(step.goal) ?? stringValue5(step.description) ?? (isUsableGeneratedStepQuery(params?.query) ? params.query : void 0) ?? fallbackQuery;
15857
- const acceptance = stringValue5(step.acceptance) ?? stringValue5(step.expected_output) ?? stringValue5(step.done_when) ?? stringValue5(step.verify);
16041
+ const query = stringValue6(step.query) ?? stringValue6(step.goal) ?? stringValue6(step.description) ?? (isUsableGeneratedStepQuery(params?.query) ? params.query : void 0) ?? fallbackQuery;
16042
+ const acceptance = stringValue6(step.acceptance) ?? stringValue6(step.expected_output) ?? stringValue6(step.done_when) ?? stringValue6(step.verify);
15858
16043
  const likelyFiles = params && step.action === "implementation_map" ? normalizeStringArray3(params.likely_files) : normalizeStringArray3(step.files) ?? normalizeStringArray3(step.files_touched) ?? normalizeStringArray3(step.paths);
15859
16044
  return {
15860
16045
  id: sanitizeWorkflowId(
15861
- stringValue5(step.id) ?? stringValue5(step.phase_id) ?? stringValue5(step.key) ?? title,
16046
+ stringValue6(step.id) ?? stringValue6(step.phase_id) ?? stringValue6(step.key) ?? title,
15862
16047
  `phase-${index + 1}`
15863
16048
  ),
15864
16049
  title,
@@ -15869,7 +16054,7 @@ function planStepToWorkflowStep(step, index, fallbackGoal) {
15869
16054
  };
15870
16055
  }
15871
16056
  function buildGeneratedWorkflowPlanDocument(plan, fallbackGoal) {
15872
- const goal = stringValue5(plan.query) ?? fallbackGoal;
16057
+ const goal = stringValue6(plan.query) ?? fallbackGoal;
15873
16058
  const steps = findWorkflowSteps(plan).map(
15874
16059
  (step, index) => planStepToWorkflowStep(step, index, goal)
15875
16060
  );
@@ -15877,7 +16062,7 @@ function buildGeneratedWorkflowPlanDocument(plan, fallbackGoal) {
15877
16062
  mode: "full",
15878
16063
  goal,
15879
16064
  source: "snipara_plan",
15880
- ...stringValue5(plan.plan_id) ? { plan_id: stringValue5(plan.plan_id) } : {},
16065
+ ...stringValue6(plan.plan_id) ? { plan_id: stringValue6(plan.plan_id) } : {},
15881
16066
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
15882
16067
  steps
15883
16068
  };
@@ -15904,7 +16089,7 @@ function booleanValue(value) {
15904
16089
  if (typeof value === "boolean") {
15905
16090
  return value;
15906
16091
  }
15907
- const text = stringValue5(value)?.toLowerCase();
16092
+ const text = stringValue6(value)?.toLowerCase();
15908
16093
  if (!text) {
15909
16094
  return void 0;
15910
16095
  }
@@ -15922,7 +16107,7 @@ function uniqueStringList(values) {
15922
16107
  }
15923
16108
  const unique3 = Array.from(
15924
16109
  new Set(
15925
- values.map((value) => stringValue5(value)).filter((value) => Boolean(value))
16110
+ values.map((value) => stringValue6(value)).filter((value) => Boolean(value))
15926
16111
  )
15927
16112
  );
15928
16113
  return unique3.length > 0 ? unique3 : void 0;
@@ -15981,15 +16166,15 @@ function normalizeWorkflowPhase2(step, index, usedIds, fallbackGoal) {
15981
16166
  status: "pending"
15982
16167
  };
15983
16168
  }
15984
- const title = stringValue5(step.title) ?? stringValue5(step.name) ?? stringValue5(step.action) ?? stringValue5(step.goal) ?? `Phase ${index + 1}`;
15985
- const query = stringValue5(step.query) ?? stringValue5(step.goal) ?? stringValue5(step.description) ?? stringValue5(step.action) ?? `${fallbackGoal}: ${title}`;
16169
+ const title = stringValue6(step.title) ?? stringValue6(step.name) ?? stringValue6(step.action) ?? stringValue6(step.goal) ?? `Phase ${index + 1}`;
16170
+ const query = stringValue6(step.query) ?? stringValue6(step.goal) ?? stringValue6(step.description) ?? stringValue6(step.action) ?? `${fallbackGoal}: ${title}`;
15986
16171
  const id = uniquePhaseId(
15987
- stringValue5(step.id) ?? stringValue5(step.phase_id) ?? stringValue5(step.key) ?? title,
16172
+ stringValue6(step.id) ?? stringValue6(step.phase_id) ?? stringValue6(step.key) ?? title,
15988
16173
  index,
15989
16174
  usedIds
15990
16175
  );
15991
16176
  const files = normalizeStringArray3(step.files) ?? normalizeStringArray3(step.files_touched) ?? normalizeStringArray3(step.paths);
15992
- const acceptance = stringValue5(step.acceptance) ?? stringValue5(step.expected_output) ?? stringValue5(step.done_when) ?? stringValue5(step.verify);
16177
+ const acceptance = stringValue6(step.acceptance) ?? stringValue6(step.expected_output) ?? stringValue6(step.done_when) ?? stringValue6(step.verify);
15993
16178
  return {
15994
16179
  id,
15995
16180
  title,
@@ -16487,7 +16672,7 @@ function runtimeCheckpointEventPayload(event) {
16487
16672
  if (!payload) {
16488
16673
  return void 0;
16489
16674
  }
16490
- const toolName = stringValue5(payload.tool_name ?? payload.toolName ?? payload.tool);
16675
+ const toolName = stringValue6(payload.tool_name ?? payload.toolName ?? payload.tool);
16491
16676
  if (toolName !== "snipara_sandbox_runtime_checkpoint") {
16492
16677
  return void 0;
16493
16678
  }
@@ -16498,8 +16683,8 @@ function parseRuntimeCheckpointFromEvent(event, workflowId, phaseId) {
16498
16683
  if (!payload) {
16499
16684
  return void 0;
16500
16685
  }
16501
- const eventWorkflowId = stringValue5(payload.workflow_id);
16502
- const eventPhaseId = stringValue5(payload.workflow_phase_id);
16686
+ const eventWorkflowId = stringValue6(payload.workflow_id);
16687
+ const eventPhaseId = stringValue6(payload.workflow_phase_id);
16503
16688
  if (eventWorkflowId !== workflowId || eventPhaseId !== phaseId) {
16504
16689
  return void 0;
16505
16690
  }
@@ -16508,14 +16693,14 @@ function parseRuntimeCheckpointFromEvent(event, workflowId, phaseId) {
16508
16693
  return void 0;
16509
16694
  }
16510
16695
  return normalizeRuntimeCheckpointRecord({
16511
- summary: stringValue5(runtimeCheckpoint.summary) ?? stringValue5(payload.task) ?? "Runtime checkpoint captured",
16512
- capturedAt: stringValue5(runtimeCheckpoint.captured_at) ?? stringValue5(event.event.timestamp) ?? event.createdAt,
16513
- automationSessionId: stringValue5(runtimeCheckpoint.automation_session_id) ?? stringValue5(event.event.session_id) ?? void 0,
16696
+ summary: stringValue6(runtimeCheckpoint.summary) ?? stringValue6(payload.task) ?? "Runtime checkpoint captured",
16697
+ capturedAt: stringValue6(runtimeCheckpoint.captured_at) ?? stringValue6(event.event.timestamp) ?? event.createdAt,
16698
+ automationSessionId: stringValue6(runtimeCheckpoint.automation_session_id) ?? stringValue6(event.event.session_id) ?? void 0,
16514
16699
  hostedEventId: event.id,
16515
16700
  hostedRecordedAt: event.createdAt,
16516
- environment: stringValue5(runtimeCheckpoint.environment),
16517
- profile: stringValue5(runtimeCheckpoint.profile),
16518
- bootstrapQuery: stringValue5(runtimeCheckpoint.bootstrap_query) ?? stringValue5(payload.task) ?? void 0,
16701
+ environment: stringValue6(runtimeCheckpoint.environment),
16702
+ profile: stringValue6(runtimeCheckpoint.profile),
16703
+ bootstrapQuery: stringValue6(runtimeCheckpoint.bootstrap_query) ?? stringValue6(payload.task) ?? void 0,
16519
16704
  files: normalizeStringArray3(runtimeCheckpoint.files) ?? normalizeStringArray3(payload.files) ?? void 0,
16520
16705
  commands: normalizeStringArray3(runtimeCheckpoint.commands) ?? normalizeStringArray3(payload.commands) ?? void 0,
16521
16706
  artifacts: normalizeStringArray3(runtimeCheckpoint.artifacts) ?? void 0,
@@ -17153,7 +17338,7 @@ function commitsMatch(left, right) {
17153
17338
  }
17154
17339
  function stringArrayField(record, key) {
17155
17340
  const value = record[key];
17156
- return Array.isArray(value) ? value.map((item) => stringValue5(item)).filter((item) => Boolean(item)) : [];
17341
+ return Array.isArray(value) ? value.map((item) => stringValue6(item)).filter((item) => Boolean(item)) : [];
17157
17342
  }
17158
17343
  function printCodeIndexFreshness(record) {
17159
17344
  const freshness = recordField(record, "index_freshness");
@@ -17161,8 +17346,8 @@ function printCodeIndexFreshness(record) {
17161
17346
  return;
17162
17347
  }
17163
17348
  const coverage = recordField(freshness, "coverage");
17164
- const indexedCommit = stringValue5(freshness.indexed_commit_sha);
17165
- const sourceCommit = stringValue5(freshness.source_commit_sha);
17349
+ const indexedCommit = stringValue6(freshness.indexed_commit_sha);
17350
+ const sourceCommit = stringValue6(freshness.source_commit_sha);
17166
17351
  const commit = indexedCommit ?? sourceCommit;
17167
17352
  const coverageText = coverage && coverage.coverage_percent !== void 0 ? `${coverage.coverage_percent}%` : void 0;
17168
17353
  const localGit = readLocalGitState();
@@ -17205,9 +17390,9 @@ function printCodeIndexFreshness(record) {
17205
17390
  console.log("");
17206
17391
  }
17207
17392
  function formatAction(record) {
17208
- const label = stringValue5(record.action) ?? stringValue5(record.code) ?? stringValue5(record.tool) ?? stringValue5(record.name) ?? "action";
17209
- const priority = stringValue5(record.priority ?? record.severity);
17210
- const reason = stringValue5(record.reason ?? record.message);
17393
+ const label = stringValue6(record.action) ?? stringValue6(record.code) ?? stringValue6(record.tool) ?? stringValue6(record.name) ?? "action";
17394
+ const priority = stringValue6(record.priority ?? record.severity);
17395
+ const reason = stringValue6(record.reason ?? record.message);
17211
17396
  const targets = stringArrayField(record, "targets");
17212
17397
  const suffix = [
17213
17398
  priority ? `[${priority}]` : void 0,
@@ -17239,9 +17424,9 @@ function printSuggestedToolList(record) {
17239
17424
  }
17240
17425
  console.log(import_chalk9.default.bold("Suggested MCP Follow-ups"));
17241
17426
  for (const suggestion of suggestions.slice(0, 5)) {
17242
- const tool = stringValue5(suggestion.tool) ?? "snipara_code_*";
17427
+ const tool = stringValue6(suggestion.tool) ?? "snipara_code_*";
17243
17428
  const args = recordField(suggestion, "arguments") ?? {};
17244
- const reason = stringValue5(suggestion.reason);
17429
+ const reason = stringValue6(suggestion.reason);
17245
17430
  console.log(`- ${tool}(${JSON.stringify(args)})${reason ? ` - ${reason}` : ""}`);
17246
17431
  }
17247
17432
  console.log("");
@@ -17896,9 +18081,9 @@ async function enrichAdaptiveRoutingWithHostedCatalog(client, routing) {
17896
18081
  const gateway = {
17897
18082
  source: "hosted_mcp",
17898
18083
  success: gatewaySucceeded,
17899
- resolutionStatus: stringValue5(result.resolution?.status),
18084
+ resolutionStatus: stringValue6(result.resolution?.status),
17900
18085
  candidateCount,
17901
- fallback: stringValue5(result.fallback) ?? stringValue5(result.resolution?.fallback) ?? "main_agent",
18086
+ fallback: stringValue6(result.fallback) ?? stringValue6(result.resolution?.fallback) ?? "main_agent",
17902
18087
  warnings: gatewayWarnings
17903
18088
  };
17904
18089
  const reasons = [
@@ -17943,7 +18128,7 @@ function normalizeAdaptiveRoutingCatalog(value) {
17943
18128
  (candidate) => Boolean(candidate) && typeof candidate === "object" && !Array.isArray(candidate)
17944
18129
  ) : [];
17945
18130
  return {
17946
- version: stringValue5(record.version),
18131
+ version: stringValue6(record.version),
17947
18132
  candidates
17948
18133
  };
17949
18134
  }
@@ -18548,7 +18733,7 @@ function normalizeSyncDocumentsPayload(payload) {
18548
18733
  const inferred = inferDocumentFormat(item.path);
18549
18734
  const kind = normalizeDocumentKind(item.kind) ?? inferred?.kind;
18550
18735
  const format = normalizeDocumentFormat(item.format) ?? inferred?.format;
18551
- const language = stringValue5(item.language) ?? void 0;
18736
+ const language = stringValue6(item.language) ?? void 0;
18552
18737
  return {
18553
18738
  path: item.path,
18554
18739
  content: item.content,
@@ -18755,7 +18940,7 @@ var REPO_DOC_FILES = /* @__PURE__ */ new Set([
18755
18940
  "SECURITY.md"
18756
18941
  ]);
18757
18942
  function normalizeOnboardFolderMode(value) {
18758
- const normalized = stringValue5(value)?.replace(/[-\s]/g, "_").toLowerCase() ?? "auto";
18943
+ const normalized = stringValue6(value)?.replace(/[-\s]/g, "_").toLowerCase() ?? "auto";
18759
18944
  if (normalized === "auto" || normalized === "business_context" || normalized === "code_project" || normalized === "mixed") {
18760
18945
  return normalized;
18761
18946
  }
@@ -19077,7 +19262,7 @@ function normalizeUsageMode(value) {
19077
19262
  function hasReferenceProvenance(metadata) {
19078
19263
  const referenceProvenance = metadata.referenceProvenance ?? metadata.reference_provenance;
19079
19264
  if (isRecord9(referenceProvenance)) {
19080
- return Object.values(referenceProvenance).some((value) => Boolean(stringValue5(value)));
19265
+ return Object.values(referenceProvenance).some((value) => Boolean(stringValue6(value)));
19081
19266
  }
19082
19267
  return [
19083
19268
  metadata.clientId,
@@ -19116,7 +19301,7 @@ function validateDocumentForDryRun(document, now) {
19116
19301
  const reasons = [];
19117
19302
  const reviewReasons = [];
19118
19303
  const reuploadReasons = [];
19119
- const assetClass = stringValue5(metadata.assetClass ?? metadata.asset_class);
19304
+ const assetClass = stringValue6(metadata.assetClass ?? metadata.asset_class);
19120
19305
  if (!isSupportedDocumentFormat(kind, format)) {
19121
19306
  reasons.push("invalid_document_format");
19122
19307
  }
@@ -19131,7 +19316,7 @@ function validateDocumentForDryRun(document, now) {
19131
19316
  if (usageModeRaw !== void 0 && !usageMode) {
19132
19317
  reasons.push("invalid_usage_mode");
19133
19318
  }
19134
- const sourceKind = stringValue5(metadata.sourceKind ?? metadata.source_kind);
19319
+ const sourceKind = stringValue6(metadata.sourceKind ?? metadata.source_kind);
19135
19320
  if (sourceKind && !SOURCE_KINDS.has(sourceKind)) {
19136
19321
  reasons.push("invalid_source_kind");
19137
19322
  }
@@ -19140,8 +19325,8 @@ function validateDocumentForDryRun(document, now) {
19140
19325
  const sourceSnapshotAtRaw = metadata.sourceSnapshotAt ?? metadata.source_snapshot_at;
19141
19326
  const sourceModifiedAt = parseIsoDate(sourceModifiedAtRaw);
19142
19327
  const sourceSnapshotAt = parseIsoDate(sourceSnapshotAtRaw);
19143
- const sourceHash = stringValue5(metadata.sourceContentHash ?? metadata.source_content_hash);
19144
- const latestHash = stringValue5(
19328
+ const sourceHash = stringValue6(metadata.sourceContentHash ?? metadata.source_content_hash);
19329
+ const latestHash = stringValue6(
19145
19330
  metadata.latestSourceContentHash ?? metadata.currentSourceContentHash ?? metadata.manifestSourceContentHash
19146
19331
  );
19147
19332
  if (sourceModifiedAtRaw !== void 0 && !sourceModifiedAt) {
@@ -19699,7 +19884,7 @@ function buildWorkflowAdaptiveRouting(options, policy = null, intentWarnings = [
19699
19884
  dailyBudgetCents: policy?.dailyBudgetCents,
19700
19885
  monthlyBudgetCents: policy?.monthlyBudgetCents
19701
19886
  });
19702
- const requestedWorkerRole = stringValue5(options.routingWorkerRole);
19887
+ const requestedWorkerRole = stringValue6(options.routingWorkerRole);
19703
19888
  let routing = buildRecommendation(requestedWorkerRole);
19704
19889
  const allowedWorkerClasses = policy?.allowedWorkerClasses ?? [];
19705
19890
  if (allowedWorkerClasses.length > 0 && !isAdaptiveWorkerClassAllowed(routing.requirements.workerRole, allowedWorkerClasses)) {
@@ -19731,12 +19916,12 @@ function buildWorkflowAdaptiveRouting(options, policy = null, intentWarnings = [
19731
19916
  function normalizeRoutingEndpointTypes(values) {
19732
19917
  return Array.from(
19733
19918
  new Set(
19734
- (values ?? []).map((value) => stringValue5(value)?.toLowerCase()).filter((value) => Boolean(value))
19919
+ (values ?? []).map((value) => stringValue6(value)?.toLowerCase()).filter((value) => Boolean(value))
19735
19920
  )
19736
19921
  ).sort();
19737
19922
  }
19738
19923
  function normalizeAdaptiveRoutingMode(value) {
19739
- const normalized = stringValue5(value)?.toLowerCase();
19924
+ const normalized = stringValue6(value)?.toLowerCase();
19740
19925
  return normalized === "off" || normalized === "recommend" || normalized === "catalog" ? normalized : null;
19741
19926
  }
19742
19927
  function normalizeAdaptiveWorkerClasses(values) {
@@ -19763,7 +19948,7 @@ function intersectStrings(left, right) {
19763
19948
  return left.filter((value) => rightSet.has(value));
19764
19949
  }
19765
19950
  function canonicalAdaptiveWorkerClass(value) {
19766
- const normalized = stringValue5(value)?.toLowerCase().replace(/[-\s]/g, "_") ?? "execution";
19951
+ const normalized = stringValue6(value)?.toLowerCase().replace(/[-\s]/g, "_") ?? "execution";
19767
19952
  if (normalized === "docs" || normalized === "doc") {
19768
19953
  return "documentation";
19769
19954
  }
@@ -20221,9 +20406,9 @@ async function workflowRuntimeCheckpointCommand(options) {
20221
20406
  summary: options.summary,
20222
20407
  capturedAt: now,
20223
20408
  automationSessionId: loadConfig().sessionId,
20224
- environment: stringValue5(options.environment) ?? binding.environment,
20225
- profile: stringValue5(options.profile) ?? binding.profile,
20226
- bootstrapQuery: stringValue5(options.bootstrapQuery) ?? binding.bootstrapQuery,
20409
+ environment: stringValue6(options.environment) ?? binding.environment,
20410
+ profile: stringValue6(options.profile) ?? binding.profile,
20411
+ bootstrapQuery: stringValue6(options.bootstrapQuery) ?? binding.bootstrapQuery,
20227
20412
  files: uniqueStringList(options.files) ?? phase.files ?? [],
20228
20413
  commands: uniqueStringList(options.commands) ?? [],
20229
20414
  artifacts: uniqueStringList([...options.artifacts ?? [], ...contextPackArtifacts]) ?? binding.artifacts ?? [],
@@ -21036,7 +21221,7 @@ program.command("verify").description("Build a transparent verification plan fro
21036
21221
  json: Boolean(options.json)
21037
21222
  });
21038
21223
  });
21039
- program.command("run").description("Run the production Project Intelligence judgment flow for a task or release").option("--task <task>", "Current task or change summary").option("--branch <branch>", "Branch to scope continuity signals").option("--changed-files <changedFiles...>", "Changed files to analyze").option("--recent-files <recentFiles...>", "Recently touched files for continuity lookup").option("--diff-summary <diffSummary>", "Natural-language summary for code impact").option("--max-tokens <number>", "Resume context token budget", "4000").option("--release", "Run release-oriented guard and package surface review").option("--skip-impact", "Do not run companion code impact").option("--skip-memory-health", "Do not call snipara_memory_health").option("--skip-guard", "Skip collaboration guard during release runs").option("--skip-package-review", "Skip npm package surface review").option("--json", "Print raw JSON").action(async (options) => {
21224
+ program.command("run").description("Run the production Project Intelligence judgment flow for a task or release").option("--task <task>", "Current task or change summary").option("--branch <branch>", "Branch to scope continuity signals").option("--changed-files <changedFiles...>", "Changed files to analyze").option("--recent-files <recentFiles...>", "Recently touched files for continuity lookup").option("--diff-summary <diffSummary>", "Natural-language summary for code impact").option("--max-tokens <number>", "Resume context token budget", "4000").option("--release", "Run release-oriented guard and package surface review").option("--skip-impact", "Do not run companion code impact").option("--skip-memory-health", "Do not call snipara_memory_health").option("--skip-guard", "Skip collaboration guard during release runs").option("--skip-package-review", "Skip npm package surface review").option("--served-judgment-id <id>", "Served judgment id to use for first-party advisor receipts").option("--skip-advisor-receipts", "Skip first-party advisor influence receipt capture").option("--json", "Print raw JSON").action(async (options) => {
21040
21225
  await projectIntelligenceRunCommand({
21041
21226
  task: options.task,
21042
21227
  branch: options.branch,
@@ -21049,6 +21234,8 @@ program.command("run").description("Run the production Project Intelligence judg
21049
21234
  skipMemoryHealth: Boolean(options.skipMemoryHealth),
21050
21235
  skipGuard: Boolean(options.skipGuard),
21051
21236
  skipPackageReview: Boolean(options.skipPackageReview),
21237
+ servedJudgmentId: options.servedJudgmentId,
21238
+ skipAdvisorReceipts: Boolean(options.skipAdvisorReceipts),
21052
21239
  json: Boolean(options.json)
21053
21240
  });
21054
21241
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snipara-companion",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Snipara Git-style companion CLI for local workflow continuity, hooks, hosted context, and Mini Snipara OSS workflows",
5
5
  "main": "dist/index.js",
6
6
  "bin": {