council-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +295 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +117 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/client.d.ts +3 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/client.js +75 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/prompts.d.ts +5 -0
- package/dist/llm/prompts.d.ts.map +1 -0
- package/dist/llm/prompts.js +115 -0
- package/dist/llm/prompts.js.map +1 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +44 -0
- package/dist/logger.js.map +1 -0
- package/dist/stages/propose.d.ts +3 -0
- package/dist/stages/propose.d.ts.map +1 -0
- package/dist/stages/propose.js +76 -0
- package/dist/stages/propose.js.map +1 -0
- package/dist/stages/rank.d.ts +3 -0
- package/dist/stages/rank.d.ts.map +1 -0
- package/dist/stages/rank.js +166 -0
- package/dist/stages/rank.js.map +1 -0
- package/dist/stages/synthesize.d.ts +3 -0
- package/dist/stages/synthesize.d.ts.map +1 -0
- package/dist/stages/synthesize.js +61 -0
- package/dist/stages/synthesize.js.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Proposal, RankerResult } from "../types";
|
|
2
|
+
export declare function getProposalPrompt(task: string): string;
|
|
3
|
+
export declare function getRankingPrompt(proposals: Proposal[]): string;
|
|
4
|
+
export declare function getSynthesisPrompt(task: string, proposals: Proposal[], rankerResults: RankerResult[]): string;
|
|
5
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/llm/prompts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEvD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWtD;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAsB9D;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,QAAQ,EAAE,EACrB,aAAa,EAAE,YAAY,EAAE,GAC5B,MAAM,CA6ER"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Prompt templates
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getProposalPrompt = getProposalPrompt;
|
|
5
|
+
exports.getRankingPrompt = getRankingPrompt;
|
|
6
|
+
exports.getSynthesisPrompt = getSynthesisPrompt;
|
|
7
|
+
function getProposalPrompt(task) {
|
|
8
|
+
return `You are a senior software architect. Create a detailed implementation plan for:
|
|
9
|
+
"${task}"
|
|
10
|
+
|
|
11
|
+
Your plan should include:
|
|
12
|
+
1. Overview of the approach
|
|
13
|
+
2. Step-by-step implementation
|
|
14
|
+
3. Key files to create/modify
|
|
15
|
+
4. Potential pitfalls and how to avoid them
|
|
16
|
+
|
|
17
|
+
Be specific and actionable. Focus on simplicity and correctness.`;
|
|
18
|
+
}
|
|
19
|
+
function getRankingPrompt(proposals) {
|
|
20
|
+
const plansText = proposals
|
|
21
|
+
.map((p, i) => `[Plan ${i + 1}]\n${p.content}`)
|
|
22
|
+
.join("\n\n---\n\n");
|
|
23
|
+
return `You are reviewing implementation plans. Score each plan from 1-10 on:
|
|
24
|
+
- Simplicity: Is it straightforward? Avoids over-engineering?
|
|
25
|
+
- Correctness: Will it work? Handles edge cases?
|
|
26
|
+
- Security: No vulnerabilities? Follows best practices?
|
|
27
|
+
- Performance: Efficient? No obvious bottlenecks?
|
|
28
|
+
|
|
29
|
+
Plans to review:
|
|
30
|
+
|
|
31
|
+
${plansText}
|
|
32
|
+
|
|
33
|
+
Respond in this exact JSON format (no markdown code blocks, just raw JSON):
|
|
34
|
+
{
|
|
35
|
+
"rankings": [
|
|
36
|
+
{"planId": 1, "simplicity": 8, "correctness": 9, "security": 7, "performance": 8, "critique": "Brief critique here"},
|
|
37
|
+
{"planId": 2, "simplicity": 7, "correctness": 8, "security": 8, "performance": 7, "critique": "Brief critique here"}
|
|
38
|
+
]
|
|
39
|
+
}`;
|
|
40
|
+
}
|
|
41
|
+
function getSynthesisPrompt(task, proposals, rankerResults) {
|
|
42
|
+
// Build plans with their scores
|
|
43
|
+
const plansWithScores = proposals.map((proposal) => {
|
|
44
|
+
const scores = rankerResults.map((result) => {
|
|
45
|
+
const ranking = result.rankings.find((r) => r.planId === proposal.proposalId);
|
|
46
|
+
if (!ranking)
|
|
47
|
+
return null;
|
|
48
|
+
return {
|
|
49
|
+
ranker: result.rankerModel,
|
|
50
|
+
scores: ranking.scores,
|
|
51
|
+
total: ranking.totalScore,
|
|
52
|
+
critique: ranking.critique,
|
|
53
|
+
};
|
|
54
|
+
}).filter(Boolean);
|
|
55
|
+
const avgTotal = scores.length > 0
|
|
56
|
+
? scores.reduce((sum, s) => sum + (s?.total || 0), 0) / scores.length
|
|
57
|
+
: 0;
|
|
58
|
+
return {
|
|
59
|
+
proposal,
|
|
60
|
+
scores,
|
|
61
|
+
avgTotal,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
// Sort by average score
|
|
65
|
+
plansWithScores.sort((a, b) => b.avgTotal - a.avgTotal);
|
|
66
|
+
const plansText = plansWithScores
|
|
67
|
+
.map((p, i) => {
|
|
68
|
+
const scoresText = p.scores
|
|
69
|
+
.map((s) => ` - ${s?.ranker}: ${s?.total}/40 - "${s?.critique}"`)
|
|
70
|
+
.join("\n");
|
|
71
|
+
return `[Plan ${i + 1}] (Avg: ${p.avgTotal.toFixed(1)}/40) by ${p.proposal.model}
|
|
72
|
+
${p.proposal.content}
|
|
73
|
+
|
|
74
|
+
Scores:
|
|
75
|
+
${scoresText}`;
|
|
76
|
+
})
|
|
77
|
+
.join("\n\n---\n\n");
|
|
78
|
+
return `You are a senior architect synthesizing the best implementation plan.
|
|
79
|
+
|
|
80
|
+
Original task: "${task}"
|
|
81
|
+
|
|
82
|
+
You have ${proposals.length} proposed plans with rankings from ${rankerResults.length} reviewers:
|
|
83
|
+
|
|
84
|
+
${plansText}
|
|
85
|
+
|
|
86
|
+
Please provide your response in the following format:
|
|
87
|
+
|
|
88
|
+
## Analysis
|
|
89
|
+
|
|
90
|
+
First, analyze each plan briefly:
|
|
91
|
+
- What are the strengths of each approach?
|
|
92
|
+
- What concerns were raised by reviewers?
|
|
93
|
+
- Which elements should be incorporated into the final plan?
|
|
94
|
+
|
|
95
|
+
## Synthesis Reasoning
|
|
96
|
+
|
|
97
|
+
Explain your thought process:
|
|
98
|
+
- Why did you choose certain approaches over others?
|
|
99
|
+
- How did you address the critiques?
|
|
100
|
+
- What trade-offs did you consider?
|
|
101
|
+
|
|
102
|
+
## Final Implementation Plan
|
|
103
|
+
|
|
104
|
+
Create a final, optimal plan that:
|
|
105
|
+
1. Takes the best ideas from top-ranked plans
|
|
106
|
+
2. Addresses concerns raised in critiques
|
|
107
|
+
3. Is clear enough to hand directly to a coding agent
|
|
108
|
+
|
|
109
|
+
Include:
|
|
110
|
+
- Overview of the approach
|
|
111
|
+
- Step-by-step implementation
|
|
112
|
+
- Key files to create/modify
|
|
113
|
+
- Potential pitfalls and how to avoid them`;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|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ean, message: string): void;
|
|
3
|
+
export declare function stageHeader(stage: number, total: number, title: string): void;
|
|
4
|
+
export declare function success(message: string): void;
|
|
5
|
+
export declare function error(message: string): void;
|
|
6
|
+
export declare function info(message: string): void;
|
|
7
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAUlD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAOnE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAE7E;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Spinners and progress
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.startSpinner = startSpinner;
|
|
5
|
+
exports.stopSpinner = stopSpinner;
|
|
6
|
+
exports.stageHeader = stageHeader;
|
|
7
|
+
exports.success = success;
|
|
8
|
+
exports.error = error;
|
|
9
|
+
exports.info = info;
|
|
10
|
+
const spinnerFrames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
11
|
+
let spinnerInterval = null;
|
|
12
|
+
let currentFrame = 0;
|
|
13
|
+
function startSpinner(message) {
|
|
14
|
+
if (spinnerInterval) {
|
|
15
|
+
clearInterval(spinnerInterval);
|
|
16
|
+
}
|
|
17
|
+
currentFrame = 0;
|
|
18
|
+
process.stdout.write(`${spinnerFrames[currentFrame]} ${message}`);
|
|
19
|
+
spinnerInterval = setInterval(() => {
|
|
20
|
+
currentFrame = (currentFrame + 1) % spinnerFrames.length;
|
|
21
|
+
process.stdout.write(`\r${spinnerFrames[currentFrame]} ${message}`);
|
|
22
|
+
}, 80);
|
|
23
|
+
}
|
|
24
|
+
function stopSpinner(success, message) {
|
|
25
|
+
if (spinnerInterval) {
|
|
26
|
+
clearInterval(spinnerInterval);
|
|
27
|
+
spinnerInterval = null;
|
|
28
|
+
}
|
|
29
|
+
const icon = success ? "✓" : "✗";
|
|
30
|
+
process.stdout.write(`\r${icon} ${message}\n`);
|
|
31
|
+
}
|
|
32
|
+
function stageHeader(stage, total, title) {
|
|
33
|
+
console.log(`\n[${stage}/${total}] ${title}`);
|
|
34
|
+
}
|
|
35
|
+
function success(message) {
|
|
36
|
+
console.log(`✓ ${message}`);
|
|
37
|
+
}
|
|
38
|
+
function error(message) {
|
|
39
|
+
console.error(`✗ ${message}`);
|
|
40
|
+
}
|
|
41
|
+
function info(message) {
|
|
42
|
+
console.log(` ${message}`);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,wBAAwB;;AAMxB,oCAUC;AAED,kCAOC;AAED,kCAEC;AAED,0BAEC;AAED,sBAEC;AAED,oBAEC;AAvCD,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACzE,IAAI,eAAe,GAA0C,IAAI,CAAC;AAClE,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB,SAAgB,YAAY,CAAC,OAAe;IAC1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AAO,EAAE,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propose.d.ts","sourceRoot":"","sources":["../../src/stages/propose.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAOjD,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAyC/E"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Stage 1: Propose
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.propose = propose;
|
|
38
|
+
const client_1 = require("../llm/client");
|
|
39
|
+
const prompts_1 = require("../llm/prompts");
|
|
40
|
+
const logger = __importStar(require("../logger"));
|
|
41
|
+
const MIN_PROPOSALS = 2;
|
|
42
|
+
async function propose(task, config) {
|
|
43
|
+
const prompt = (0, prompts_1.getProposalPrompt)(task);
|
|
44
|
+
const models = config.proposer_models;
|
|
45
|
+
logger.info(`Calling ${models.length} models in parallel...`);
|
|
46
|
+
const results = await Promise.allSettled(models.map(async (model, index) => {
|
|
47
|
+
logger.startSpinner(`${model}...`);
|
|
48
|
+
try {
|
|
49
|
+
const content = await (0, client_1.callLLM)(config.openrouter_api_key, model, [
|
|
50
|
+
{ role: "user", content: prompt },
|
|
51
|
+
]);
|
|
52
|
+
logger.stopSpinner(true, `${model} ✓`);
|
|
53
|
+
return {
|
|
54
|
+
proposalId: index + 1,
|
|
55
|
+
model,
|
|
56
|
+
content,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
logger.stopSpinner(false, `${model} failed: ${error.message}`);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
const proposals = [];
|
|
65
|
+
for (const result of results) {
|
|
66
|
+
if (result.status === "fulfilled") {
|
|
67
|
+
proposals.push(result.value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (proposals.length < MIN_PROPOSALS) {
|
|
71
|
+
throw new Error(`Only ${proposals.length} proposals succeeded. Minimum ${MIN_PROPOSALS} required.`);
|
|
72
|
+
}
|
|
73
|
+
logger.info(`${proposals.length}/${models.length} proposals generated successfully`);
|
|
74
|
+
return proposals;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=propose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propose.js","sourceRoot":"","sources":["../../src/stages/propose.ts"],"names":[],"mappings":";AAAA,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASnB,0BAyCC;AA/CD,0CAAwC;AACxC,4CAAmD;AACnD,kDAAoC;AAEpC,MAAM,aAAa,GAAG,CAAC,CAAC;AAEjB,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,MAAc;IACxD,MAAM,MAAM,GAAG,IAAA,2BAAiB,EAAC,IAAI,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;IAEtC,MAAM,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,MAAM,wBAAwB,CAAC,CAAC;IAE9D,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACtC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAChC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAA,gBAAO,EAAC,MAAM,CAAC,kBAAkB,EAAE,KAAK,EAAE;gBAC9D,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;aAClC,CAAC,CAAC;YACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;YACvC,OAAO;gBACL,UAAU,EAAE,KAAK,GAAG,CAAC;gBACrB,KAAK;gBACL,OAAO;aACI,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,KAAK,YAAa,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,SAAS,GAAe,EAAE,CAAC;IACjC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,GAAG,aAAa,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,QAAQ,SAAS,CAAC,MAAM,iCAAiC,aAAa,YAAY,CACnF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,mCAAmC,CAAC,CAAC;IACrF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rank.d.ts","sourceRoot":"","sources":["../../src/stages/rank.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAe,YAAY,EAAE,MAAM,UAAU,CAAC;AAmH5E,wBAAsB,IAAI,CACxB,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,YAAY,EAAE,CAAC,CAiDzB"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Stage 2: Rank
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.rank = rank;
|
|
38
|
+
const client_1 = require("../llm/client");
|
|
39
|
+
const prompts_1 = require("../llm/prompts");
|
|
40
|
+
const logger = __importStar(require("../logger"));
|
|
41
|
+
// Fisher-Yates shuffle
|
|
42
|
+
function shuffle(array) {
|
|
43
|
+
const shuffled = [...array];
|
|
44
|
+
const indexMap = new Map();
|
|
45
|
+
// Initialize index map
|
|
46
|
+
for (let i = 0; i < shuffled.length; i++) {
|
|
47
|
+
indexMap.set(i, i);
|
|
48
|
+
}
|
|
49
|
+
for (let i = shuffled.length - 1; i > 0; i--) {
|
|
50
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
51
|
+
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
|
|
52
|
+
// Update index map
|
|
53
|
+
const tempI = indexMap.get(i);
|
|
54
|
+
const tempJ = indexMap.get(j);
|
|
55
|
+
indexMap.set(i, tempJ);
|
|
56
|
+
indexMap.set(j, tempI);
|
|
57
|
+
}
|
|
58
|
+
return { shuffled, indexMap };
|
|
59
|
+
}
|
|
60
|
+
function parseRankingResponse(response) {
|
|
61
|
+
// Try to parse JSON directly
|
|
62
|
+
try {
|
|
63
|
+
// Remove markdown code blocks if present
|
|
64
|
+
let cleaned = response.trim();
|
|
65
|
+
if (cleaned.startsWith("```json")) {
|
|
66
|
+
cleaned = cleaned.slice(7);
|
|
67
|
+
}
|
|
68
|
+
else if (cleaned.startsWith("```")) {
|
|
69
|
+
cleaned = cleaned.slice(3);
|
|
70
|
+
}
|
|
71
|
+
if (cleaned.endsWith("```")) {
|
|
72
|
+
cleaned = cleaned.slice(0, -3);
|
|
73
|
+
}
|
|
74
|
+
cleaned = cleaned.trim();
|
|
75
|
+
const parsed = JSON.parse(cleaned);
|
|
76
|
+
if (parsed.rankings && Array.isArray(parsed.rankings)) {
|
|
77
|
+
return parsed.rankings;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// JSON parsing failed, try regex fallback
|
|
82
|
+
}
|
|
83
|
+
// Regex fallback for malformed JSON
|
|
84
|
+
const rankings = [];
|
|
85
|
+
const planRegex = /planId["\s:]+(\d+)[^}]*simplicity["\s:]+(\d+)[^}]*correctness["\s:]+(\d+)[^}]*security["\s:]+(\d+)[^}]*performance["\s:]+(\d+)[^}]*critique["\s:]+["']([^"']+)["']/gi;
|
|
86
|
+
let match;
|
|
87
|
+
while ((match = planRegex.exec(response)) !== null) {
|
|
88
|
+
rankings.push({
|
|
89
|
+
planId: parseInt(match[1]),
|
|
90
|
+
simplicity: parseInt(match[2]),
|
|
91
|
+
correctness: parseInt(match[3]),
|
|
92
|
+
security: parseInt(match[4]),
|
|
93
|
+
performance: parseInt(match[5]),
|
|
94
|
+
critique: match[6],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return rankings;
|
|
98
|
+
}
|
|
99
|
+
function mapShuffledToOriginal(rankings, indexMap, proposals) {
|
|
100
|
+
return rankings.map((r) => {
|
|
101
|
+
// shuffledIndex is 0-based (planId - 1)
|
|
102
|
+
const shuffledIndex = r.planId - 1;
|
|
103
|
+
// Find original proposal
|
|
104
|
+
let originalProposalId = r.planId;
|
|
105
|
+
// Map back to original proposal ID
|
|
106
|
+
for (const [shuffledIdx, origIdx] of indexMap.entries()) {
|
|
107
|
+
if (shuffledIdx === shuffledIndex) {
|
|
108
|
+
originalProposalId = proposals[origIdx]?.proposalId || r.planId;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const totalScore = r.simplicity + r.correctness + r.security + r.performance;
|
|
113
|
+
return {
|
|
114
|
+
planId: originalProposalId,
|
|
115
|
+
scores: {
|
|
116
|
+
simplicity: r.simplicity,
|
|
117
|
+
correctness: r.correctness,
|
|
118
|
+
security: r.security,
|
|
119
|
+
performance: r.performance,
|
|
120
|
+
},
|
|
121
|
+
totalScore,
|
|
122
|
+
critique: r.critique,
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async function rank(proposals, config) {
|
|
127
|
+
// Shuffle proposals for blind ranking
|
|
128
|
+
const { shuffled, indexMap } = shuffle(proposals);
|
|
129
|
+
const prompt = (0, prompts_1.getRankingPrompt)(shuffled);
|
|
130
|
+
const models = config.proposer_models; // Same models rank each other
|
|
131
|
+
logger.info(`${models.length} models ranking ${proposals.length} plans blindly...`);
|
|
132
|
+
const results = await Promise.allSettled(models.map(async (model) => {
|
|
133
|
+
logger.startSpinner(`${model} ranking...`);
|
|
134
|
+
try {
|
|
135
|
+
const response = await (0, client_1.callLLM)(config.openrouter_api_key, model, [
|
|
136
|
+
{ role: "user", content: prompt },
|
|
137
|
+
]);
|
|
138
|
+
const rawRankings = parseRankingResponse(response);
|
|
139
|
+
if (rawRankings.length === 0) {
|
|
140
|
+
throw new Error("Failed to parse ranking response");
|
|
141
|
+
}
|
|
142
|
+
const rankings = mapShuffledToOriginal(rawRankings, indexMap, proposals);
|
|
143
|
+
logger.stopSpinner(true, `${model} ranked ✓`);
|
|
144
|
+
return {
|
|
145
|
+
rankerModel: model,
|
|
146
|
+
rankings,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
logger.stopSpinner(false, `${model} ranking failed: ${error.message}`);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}));
|
|
154
|
+
const rankerResults = [];
|
|
155
|
+
for (const result of results) {
|
|
156
|
+
if (result.status === "fulfilled") {
|
|
157
|
+
rankerResults.push(result.value);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (rankerResults.length === 0) {
|
|
161
|
+
throw new Error("All ranking attempts failed");
|
|
162
|
+
}
|
|
163
|
+
logger.info(`${rankerResults.length}/${models.length} rankers completed successfully`);
|
|
164
|
+
return rankerResults;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=rank.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rank.js","sourceRoot":"","sources":["../../src/stages/rank.ts"],"names":[],"mappings":";AAAA,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqHhB,oBAoDC;AAtKD,0CAAwC;AACxC,4CAAkD;AAClD,kDAAoC;AAEpC,uBAAuB;AACvB,SAAS,OAAO,CAAI,KAAU;IAC5B,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAC5B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE3C,uBAAuB;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EA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CAAC;IAED,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,iCAAiC,CAAC,CAAC;IACvF,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/stages/synthesize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAKhF,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,QAAQ,EAAE,EACrB,QAAQ,EAAE,YAAY,EAAE,EACxB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,CAAC,CAsB1B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Stage 3: Synthesize
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.synthesize = synthesize;
|
|
38
|
+
const client_1 = require("../llm/client");
|
|
39
|
+
const prompts_1 = require("../llm/prompts");
|
|
40
|
+
const logger = __importStar(require("../logger"));
|
|
41
|
+
async function synthesize(task, proposals, rankings, config) {
|
|
42
|
+
const prompt = (0, prompts_1.getSynthesisPrompt)(task, proposals, rankings);
|
|
43
|
+
const chairmanModel = config.chairman_model;
|
|
44
|
+
logger.info(`Chairman (${chairmanModel}) synthesizing final plan...`);
|
|
45
|
+
logger.startSpinner(`${chairmanModel} thinking...`);
|
|
46
|
+
try {
|
|
47
|
+
const finalPlan = await (0, client_1.callLLM)(config.openrouter_api_key, chairmanModel, [
|
|
48
|
+
{ role: "user", content: prompt },
|
|
49
|
+
]);
|
|
50
|
+
logger.stopSpinner(true, `${chairmanModel} synthesis complete ✓`);
|
|
51
|
+
return {
|
|
52
|
+
finalPlan,
|
|
53
|
+
chairmanModel,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
logger.stopSpinner(false, `${chairmanModel} synthesis failed`);
|
|
58
|
+
throw new Error(`Synthesis failed: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=synthesize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesize.js","sourceRoot":"","sources":["../../src/stages/synthesize.ts"],"names":[],"mappings":";AAAA,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOtB,gCA2BC;AA/BD,0CAAwC;AACxC,4CAAoD;AACpD,kDAAoC;AAE7B,KAAK,UAAU,UAAU,CAC9B,IAAY,EACZ,SAAqB,EACrB,QAAwB,EACxB,MAAc;IAEd,MAAM,MAAM,GAAG,IAAA,4BAAkB,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC;IAE5C,MAAM,CAAC,IAAI,CAAC,aAAa,aAAa,8BAA8B,CAAC,CAAC;IACtE,MAAM,CAAC,YAAY,CAAC,GAAG,aAAa,cAAc,CAAC,CAAC;IAEpD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,IAAA,gBAAO,EAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,EAAE;YACxE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;SAClC,CAAC,CAAC;QAEH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,aAAa,uBAAuB,CAAC,CAAC;QAElE,OAAO;YACL,SAAS;YACT,aAAa;SACd,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,aAAa,mBAAmB,CAAC,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,qBAAsB,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
openrouter_api_key: string;
|
|
3
|
+
proposer_models: string[];
|
|
4
|
+
chairman_model: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Proposal {
|
|
7
|
+
proposalId: number;
|
|
8
|
+
model: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PlanRanking {
|
|
12
|
+
planId: number;
|
|
13
|
+
scores: {
|
|
14
|
+
simplicity: number;
|
|
15
|
+
correctness: number;
|
|
16
|
+
security: number;
|
|
17
|
+
performance: number;
|
|
18
|
+
};
|
|
19
|
+
totalScore: number;
|
|
20
|
+
critique: string;
|
|
21
|
+
}
|
|
22
|
+
export interface RankerResult {
|
|
23
|
+
rankerModel: string;
|
|
24
|
+
rankings: PlanRanking[];
|
|
25
|
+
}
|
|
26
|
+
export interface SynthesisResult {
|
|
27
|
+
finalPlan: string;
|
|
28
|
+
chairmanModel: string;
|
|
29
|
+
}
|
|
30
|
+
export interface Message {
|
|
31
|
+
role: "system" | "user" | "assistant";
|
|
32
|
+
content: string;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,MAAM;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;CACxB;AAGD,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AAGD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAGD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,iBAAiB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "council-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AI-powered implementation planning using multiple LLMs that debate and synthesize the best approach",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"council": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"prepublishOnly": "npm run build",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"dev": "npx tsx src/index.ts"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"cli",
|
|
22
|
+
"ai",
|
|
23
|
+
"llm",
|
|
24
|
+
"planning",
|
|
25
|
+
"openrouter",
|
|
26
|
+
"gpt",
|
|
27
|
+
"claude",
|
|
28
|
+
"gemini"
|
|
29
|
+
],
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"js-yaml": "^4.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/js-yaml": "^4.0.9",
|
|
40
|
+
"@types/node": "^20.0.0",
|
|
41
|
+
"typescript": "^5.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|