newtype-profile 1.0.14 → 1.0.16

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/cli/index.js CHANGED
@@ -2253,7 +2253,7 @@ var require_picocolors = __commonJS((exports, module) => {
2253
2253
  var require_package = __commonJS((exports, module) => {
2254
2254
  module.exports = {
2255
2255
  name: "newtype-profile",
2256
- version: "1.0.14",
2256
+ version: "1.0.16",
2257
2257
  description: "AI Agent Collaboration System for Content Creation - Based on oh-my-opencode",
2258
2258
  main: "dist/index.js",
2259
2259
  types: "dist/index.d.ts",
@@ -1,14 +1,16 @@
1
1
  /**
2
- * Confidence-based routing for fact-check results
2
+ * Confidence-based routing for agent outputs
3
3
  *
4
- * Parses confidence scores from fact-checker output and generates
4
+ * Parses confidence scores from agent outputs and generates
5
5
  * routing recommendations for the orchestrator.
6
6
  */
7
+ export type AgentType = "fact-checker" | "researcher" | "writer" | "editor";
7
8
  export type Recommendation = "pass" | "polish" | "rewrite" | "escalate";
8
9
  export interface ConfidenceResult {
9
10
  confidence: number | null;
10
11
  recommendation: Recommendation | null;
11
12
  directive: string | null;
13
+ agentType?: AgentType;
12
14
  }
13
15
  /**
14
16
  * Extract confidence score from fact-checker output
@@ -20,13 +22,13 @@ export declare function extractConfidence(output: string): number | null;
20
22
  */
21
23
  export declare function getRecommendation(confidence: number): "pass" | "polish" | "rewrite";
22
24
  /**
23
- * Get current rewrite attempt count for a session
25
+ * Get current rewrite attempt count for a session and agent type
24
26
  */
25
- export declare function getRewriteAttempts(sessionId: string): number;
27
+ export declare function getRewriteAttempts(sessionId: string, agentType: AgentType): number;
26
28
  /**
27
- * Increment and return the new rewrite attempt count
29
+ * Increment and return the new rewrite attempt count for a session and agent type
28
30
  */
29
- export declare function incrementRewriteAttempts(sessionId: string): number;
31
+ export declare function incrementRewriteAttempts(sessionId: string, agentType: AgentType): number;
30
32
  /**
31
33
  * Clear rewrite attempts for a session (call on session cleanup)
32
34
  */
@@ -34,7 +36,7 @@ export declare function clearRewriteAttempts(sessionId: string): void;
34
36
  /**
35
37
  * Build routing directive for Chief based on confidence
36
38
  */
37
- export declare function buildConfidenceDirective(confidence: number, sessionId: string): string;
39
+ export declare function buildConfidenceDirective(confidence: number, sessionId: string, agentType?: AgentType): string;
38
40
  /**
39
41
  * Build escalate directive when max rewrite attempts exceeded
40
42
  */
@@ -44,7 +46,19 @@ export declare function buildEscalateDirective(confidence: number, attempts: num
44
46
  * Tracks rewrite attempts and escalates after MAX_REWRITE_ATTEMPTS
45
47
  */
46
48
  export declare function analyzeFactCheckOutput(output: string, sessionId: string): ConfidenceResult;
49
+ /**
50
+ * Generic analyzer for any agent type with confidence scoring
51
+ */
52
+ export declare function analyzeAgentOutput(output: string, sessionId: string, agentType: AgentType): ConfidenceResult;
47
53
  /**
48
54
  * Check if output is from a fact-check task
49
55
  */
50
56
  export declare function isFactCheckOutput(output: string): boolean;
57
+ /**
58
+ * Detect agent type from output content
59
+ */
60
+ export declare function detectAgentType(output: string, category?: string): AgentType | null;
61
+ /**
62
+ * Check if output contains a confidence score
63
+ */
64
+ export declare function hasConfidenceScore(output: string): boolean;
package/dist/index.js CHANGED
@@ -22915,46 +22915,139 @@ function getRecommendation(confidence) {
22915
22915
  return "rewrite";
22916
22916
  }
22917
22917
  }
22918
- function getRewriteAttempts(sessionId) {
22919
- return rewriteAttempts.get(sessionId) ?? 0;
22920
- }
22921
- function incrementRewriteAttempts(sessionId) {
22922
- const current = getRewriteAttempts(sessionId);
22918
+ function incrementRewriteAttempts(sessionId, agentType) {
22919
+ let sessionMap = rewriteAttempts.get(sessionId);
22920
+ if (!sessionMap) {
22921
+ sessionMap = new Map;
22922
+ rewriteAttempts.set(sessionId, sessionMap);
22923
+ }
22924
+ const current = sessionMap.get(agentType) ?? 0;
22923
22925
  const next = current + 1;
22924
- rewriteAttempts.set(sessionId, next);
22926
+ sessionMap.set(agentType, next);
22925
22927
  return next;
22926
22928
  }
22927
22929
  function clearRewriteAttempts(sessionId) {
22928
22930
  rewriteAttempts.delete(sessionId);
22929
22931
  }
22930
- function buildConfidenceDirective(confidence, sessionId) {
22932
+ function buildConfidenceDirective(confidence, sessionId, agentType = "fact-checker") {
22931
22933
  const recommendation = getRecommendation(confidence);
22932
22934
  const confidencePercent = Math.round(confidence * 100);
22935
+ const agentLabels = {
22936
+ "fact-checker": "FACT-CHECK",
22937
+ researcher: "RESEARCH",
22938
+ writer: "DRAFT",
22939
+ editor: "EDIT"
22940
+ };
22941
+ const label = agentLabels[agentType];
22933
22942
  switch (recommendation) {
22934
22943
  case "pass":
22935
- return `[FACT-CHECK PASSED]
22944
+ return `[${label} PASSED]
22936
22945
  Confidence: ${confidencePercent}% (HIGH)
22937
- Action: Content verified. Ready for delivery.`;
22946
+ Action: ${getPassAction(agentType)}`;
22938
22947
  case "polish":
22939
- return `[FACT-CHECK: NEEDS POLISH]
22948
+ return `[${label}: NEEDS POLISH]
22940
22949
  Confidence: ${confidencePercent}% (MEDIUM)
22941
- Action: Send to Editor for refinement.
22950
+ Action: ${getPolishAction(agentType)}
22942
22951
 
22943
22952
  REQUIRED: Call chief_task with:
22944
- category="editing"
22945
- prompt="Polish the content based on fact-check feedback. Address minor uncertainties while preserving verified claims."
22953
+ category="${getPolishCategory(agentType)}"
22954
+ prompt="${getPolishPrompt(agentType)}"
22946
22955
  resume="${sessionId}"`;
22947
22956
  case "rewrite":
22948
- return `[FACT-CHECK: NEEDS REWRITE]
22957
+ return `[${label}: NEEDS REWRITE]
22949
22958
  Confidence: ${confidencePercent}% (LOW)
22950
- Action: Significant issues found. Send back to Writer.
22959
+ Action: ${getRewriteAction(agentType)}
22951
22960
 
22952
22961
  REQUIRED: Call chief_task with:
22953
- category="writing"
22954
- prompt="Rewrite the content addressing the fact-check issues. Focus on: [list specific issues from fact-check report]"
22962
+ category="${getRewriteCategory(agentType)}"
22963
+ prompt="${getRewritePrompt(agentType)}"
22955
22964
  resume="${sessionId}"`;
22956
22965
  }
22957
22966
  }
22967
+ function getPassAction(agentType) {
22968
+ switch (agentType) {
22969
+ case "fact-checker":
22970
+ return "Content verified. Ready for delivery.";
22971
+ case "researcher":
22972
+ return "Research complete. Proceed to writing.";
22973
+ case "writer":
22974
+ return "Draft complete. Send to editor.";
22975
+ case "editor":
22976
+ return "Edit complete. Send to fact-check.";
22977
+ }
22978
+ }
22979
+ function getPolishAction(agentType) {
22980
+ switch (agentType) {
22981
+ case "fact-checker":
22982
+ return "Send to Editor for refinement.";
22983
+ case "researcher":
22984
+ return "Needs additional research on specific gaps.";
22985
+ case "writer":
22986
+ return "Draft needs improvement before editing.";
22987
+ case "editor":
22988
+ return "Needs another editing pass.";
22989
+ }
22990
+ }
22991
+ function getPolishCategory(agentType) {
22992
+ switch (agentType) {
22993
+ case "fact-checker":
22994
+ return "editing";
22995
+ case "researcher":
22996
+ return "research";
22997
+ case "writer":
22998
+ return "writing";
22999
+ case "editor":
23000
+ return "editing";
23001
+ }
23002
+ }
23003
+ function getPolishPrompt(agentType) {
23004
+ switch (agentType) {
23005
+ case "fact-checker":
23006
+ return "Polish the content based on fact-check feedback. Address minor uncertainties while preserving verified claims.";
23007
+ case "researcher":
23008
+ return "Continue research on the identified gaps. Focus on: [list specific gaps from research report]";
23009
+ case "writer":
23010
+ return "Improve the draft addressing the identified issues. Focus on: [list specific issues]";
23011
+ case "editor":
23012
+ return "Continue editing to address remaining issues. Focus on: [list specific issues]";
23013
+ }
23014
+ }
23015
+ function getRewriteAction(agentType) {
23016
+ switch (agentType) {
23017
+ case "fact-checker":
23018
+ return "Significant issues found. Send back to Writer.";
23019
+ case "researcher":
23020
+ return "Research insufficient. Restart with different approach.";
23021
+ case "writer":
23022
+ return "Draft has fundamental issues. Needs major revision.";
23023
+ case "editor":
23024
+ return "Content not ready for editing. Send back to Writer.";
23025
+ }
23026
+ }
23027
+ function getRewriteCategory(agentType) {
23028
+ switch (agentType) {
23029
+ case "fact-checker":
23030
+ return "writing";
23031
+ case "researcher":
23032
+ return "research";
23033
+ case "writer":
23034
+ return "writing";
23035
+ case "editor":
23036
+ return "writing";
23037
+ }
23038
+ }
23039
+ function getRewritePrompt(agentType) {
23040
+ switch (agentType) {
23041
+ case "fact-checker":
23042
+ return "Rewrite the content addressing the fact-check issues. Focus on: [list specific issues from fact-check report]";
23043
+ case "researcher":
23044
+ return "Restart research with a different approach. Previous attempt was insufficient because: [list reasons]";
23045
+ case "writer":
23046
+ return "Rewrite the draft addressing fundamental issues. Focus on: [list specific issues]";
23047
+ case "editor":
23048
+ return "Content needs rewriting before editing. Issues: [list specific issues]";
23049
+ }
23050
+ }
22958
23051
  function buildEscalateDirective(confidence, attempts) {
22959
23052
  const confidencePercent = Math.round(confidence * 100);
22960
23053
  return `[FACT-CHECK: ESCALATE TO USER]
@@ -22977,43 +23070,74 @@ Possible user decisions:
22977
23070
  - Manually revise the problematic claims
22978
23071
  - Abandon this content direction`;
22979
23072
  }
22980
- function analyzeFactCheckOutput(output, sessionId) {
23073
+ function analyzeAgentOutput(output, sessionId, agentType) {
22981
23074
  const confidence = extractConfidence(output);
22982
23075
  if (confidence === null) {
22983
23076
  return {
22984
23077
  confidence: null,
22985
23078
  recommendation: null,
22986
- directive: null
23079
+ directive: null,
23080
+ agentType
22987
23081
  };
22988
23082
  }
22989
23083
  const baseRecommendation = getRecommendation(confidence);
22990
23084
  if (baseRecommendation === "rewrite") {
22991
- const attempts = incrementRewriteAttempts(sessionId);
23085
+ const attempts = incrementRewriteAttempts(sessionId, agentType);
22992
23086
  if (attempts > MAX_REWRITE_ATTEMPTS) {
22993
23087
  return {
22994
23088
  confidence,
22995
23089
  recommendation: "escalate",
22996
- directive: buildEscalateDirective(confidence, attempts)
23090
+ directive: buildEscalateDirective(confidence, attempts),
23091
+ agentType
22997
23092
  };
22998
23093
  }
22999
- const directive2 = buildConfidenceDirective(confidence, sessionId) + `
23094
+ const directive2 = buildConfidenceDirective(confidence, sessionId, agentType) + `
23000
23095
 
23001
23096
  Rewrite attempt: ${attempts}/${MAX_REWRITE_ATTEMPTS}`;
23002
23097
  return {
23003
23098
  confidence,
23004
23099
  recommendation: "rewrite",
23005
- directive: directive2
23100
+ directive: directive2,
23101
+ agentType
23006
23102
  };
23007
23103
  }
23008
- const directive = buildConfidenceDirective(confidence, sessionId);
23104
+ const directive = buildConfidenceDirective(confidence, sessionId, agentType);
23009
23105
  return {
23010
23106
  confidence,
23011
23107
  recommendation: baseRecommendation,
23012
- directive
23108
+ directive,
23109
+ agentType
23013
23110
  };
23014
23111
  }
23015
- function isFactCheckOutput(output) {
23016
- return output.includes("CONFIDENCE:") || output.toLowerCase().includes("fact-check") || output.includes("\u6838\u67E5") || output.includes("verification");
23112
+ function detectAgentType(output, category) {
23113
+ if (category) {
23114
+ const categoryToAgent = {
23115
+ "fact-check": "fact-checker",
23116
+ research: "researcher",
23117
+ writing: "writer",
23118
+ editing: "editor"
23119
+ };
23120
+ if (categoryToAgent[category]) {
23121
+ return categoryToAgent[category];
23122
+ }
23123
+ }
23124
+ const lowerOutput = output.toLowerCase();
23125
+ if (lowerOutput.includes("fact-check") || lowerOutput.includes("verification") || output.includes("\u6838\u67E5")) {
23126
+ return "fact-checker";
23127
+ }
23128
+ if (lowerOutput.includes("research") || lowerOutput.includes("findings") || lowerOutput.includes("sources found")) {
23129
+ return "researcher";
23130
+ }
23131
+ if (lowerOutput.includes("edited") || lowerOutput.includes("polished") || lowerOutput.includes("revised")) {
23132
+ return "editor";
23133
+ }
23134
+ if (lowerOutput.includes("draft") || lowerOutput.includes("wrote") || lowerOutput.includes("created content")) {
23135
+ return "writer";
23136
+ }
23137
+ return null;
23138
+ }
23139
+ function hasConfidenceScore(output) {
23140
+ return extractConfidence(output) !== null;
23017
23141
  }
23018
23142
 
23019
23143
  // src/hooks/chief-orchestrator/index.ts
@@ -23590,19 +23714,23 @@ ${buildOrchestratorReminder(boulderState.plan_name, progress, subagentSessionId)
23590
23714
  const summarized = summarizeOutput(output.output, { category });
23591
23715
  const formattedSummary = formatSummarizedOutput(summarized);
23592
23716
  let confidenceDirective = "";
23593
- if (isFactCheckOutput(output.output)) {
23594
- const confidenceResult = analyzeFactCheckOutput(output.output, subagentSessionId);
23595
- if (confidenceResult.directive) {
23596
- confidenceDirective = `
23717
+ if (hasConfidenceScore(output.output)) {
23718
+ const agentType = detectAgentType(output.output, category);
23719
+ if (agentType) {
23720
+ const confidenceResult = analyzeAgentOutput(output.output, subagentSessionId, agentType);
23721
+ if (confidenceResult.directive) {
23722
+ confidenceDirective = `
23597
23723
 
23598
23724
  ---
23599
23725
  ${confidenceResult.directive}
23600
23726
  ---`;
23601
- log(`[${HOOK_NAME6}] Confidence routing detected`, {
23602
- sessionID: input.sessionID,
23603
- confidence: confidenceResult.confidence,
23604
- recommendation: confidenceResult.recommendation
23605
- });
23727
+ log(`[${HOOK_NAME6}] Confidence routing detected`, {
23728
+ sessionID: input.sessionID,
23729
+ agentType,
23730
+ confidence: confidenceResult.confidence,
23731
+ recommendation: confidenceResult.recommendation
23732
+ });
23733
+ }
23606
23734
  }
23607
23735
  }
23608
23736
  output.output = `${formattedSummary}
@@ -49284,7 +49412,23 @@ Always structure your findings as:
49284
49412
  - Use web search aggressively
49285
49413
  - Follow promising leads with targeted follow-up searches
49286
49414
  - When a source looks valuable, extract key quotes with attribution
49287
- </Tool_Usage>`
49415
+ </Tool_Usage>
49416
+
49417
+ <Confidence_Score>
49418
+ ## Research Completeness Score (REQUIRED)
49419
+ After completing your research, you MUST end your response with a confidence score in this EXACT format:
49420
+
49421
+ ---
49422
+ **CONFIDENCE: X.XX**
49423
+
49424
+ Where X.XX is a number between 0.00 and 1.00:
49425
+ - 0.90-1.00: Comprehensive coverage, multiple authoritative sources, all angles explored
49426
+ - 0.70-0.89: Good coverage, reliable sources, but some gaps or limited perspectives
49427
+ - 0.50-0.69: Partial coverage, mixed source quality, significant gaps remain
49428
+ - 0.00-0.49: Limited findings, unreliable sources, or topic poorly understood
49429
+
49430
+ This score helps Chief decide if more research is needed before proceeding.
49431
+ </Confidence_Score>`
49288
49432
  };
49289
49433
  }
49290
49434
  var researcherAgent = createResearcherAgent();
@@ -49569,7 +49713,23 @@ You take research, source materials, and briefs, then produce structured, engagi
49569
49713
  - Done is better than perfect (that's editor's job)
49570
49714
  - Structure is your foundation \u2014 get that right first
49571
49715
  - When stuck, write badly first, then improve
49572
- </Mindset>`
49716
+ </Mindset>
49717
+
49718
+ <Confidence_Score>
49719
+ ## Draft Quality Score (REQUIRED)
49720
+ After completing your draft, you MUST end your response with a confidence score in this EXACT format:
49721
+
49722
+ ---
49723
+ **CONFIDENCE: X.XX**
49724
+
49725
+ Where X.XX is a number between 0.00 and 1.00:
49726
+ - 0.90-1.00: Complete draft, strong structure, well-grounded in sources, ready for editing
49727
+ - 0.70-0.89: Solid draft, minor gaps or rough sections, needs polish
49728
+ - 0.50-0.69: Partial draft, structural issues or missing sections, needs significant work
49729
+ - 0.00-0.49: Incomplete or problematic draft, fundamental issues with structure or content
49730
+
49731
+ This score helps Chief decide if the draft needs revision before sending to Editor.
49732
+ </Confidence_Score>`
49573
49733
  };
49574
49734
  }
49575
49735
  var writerAgent = createWriterAgent();
@@ -49638,7 +49798,23 @@ You take drafts and make them excellent. You improve clarity, strengthen logic,
49638
49798
  - Every word should earn its place
49639
49799
  - Clarity > cleverness
49640
49800
  - Your job is to make the writer look good
49641
- </Mindset>`
49801
+ </Mindset>
49802
+
49803
+ <Confidence_Score>
49804
+ ## Edit Quality Score (REQUIRED)
49805
+ After completing your edit, you MUST end your response with a confidence score in this EXACT format:
49806
+
49807
+ ---
49808
+ **CONFIDENCE: X.XX**
49809
+
49810
+ Where X.XX is a number between 0.00 and 1.00:
49811
+ - 0.90-1.00: Polished and ready for publication, no remaining issues
49812
+ - 0.70-0.89: Good quality, minor improvements possible but acceptable
49813
+ - 0.50-0.69: Needs another pass, structural or clarity issues remain
49814
+ - 0.00-0.49: Significant problems, requires substantial revision or rewrite
49815
+
49816
+ This score helps Chief decide if the content is ready for fact-check or needs more work.
49817
+ </Confidence_Score>`
49642
49818
  };
49643
49819
  }
49644
49820
  var editorAgent = createEditorAgent();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newtype-profile",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "AI Agent Collaboration System for Content Creation - Based on oh-my-opencode",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",