@thispointon/kondi-chat 0.1.2
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/LICENSE +21 -0
- package/README.md +556 -0
- package/bin/kondi-chat +56 -0
- package/bin/kondi-chat.js +72 -0
- package/package.json +55 -0
- package/scripts/demo.tape +49 -0
- package/scripts/postinstall.cjs +103 -0
- package/src/audit/analytics.ts +261 -0
- package/src/audit/ledger.ts +253 -0
- package/src/audit/telemetry.ts +165 -0
- package/src/cli/backend.ts +675 -0
- package/src/cli/commands.ts +419 -0
- package/src/cli/help.ts +182 -0
- package/src/cli/submit-helpers.ts +159 -0
- package/src/cli/submit.ts +539 -0
- package/src/cli/wizard.ts +121 -0
- package/src/context/bootstrap.ts +138 -0
- package/src/context/budget.ts +100 -0
- package/src/context/manager.ts +666 -0
- package/src/context/memory.ts +160 -0
- package/src/context/preflight.ts +176 -0
- package/src/context/project-brain.ts +101 -0
- package/src/context/receipts.ts +108 -0
- package/src/context/skills.ts +154 -0
- package/src/context/symbol-index.ts +240 -0
- package/src/council/profiles.ts +137 -0
- package/src/council/tool.ts +138 -0
- package/src/council-engine/cli/council-artifacts.ts +230 -0
- package/src/council-engine/cli/council-config.ts +178 -0
- package/src/council-engine/cli/council-session-export.ts +116 -0
- package/src/council-engine/cli/kondi.ts +98 -0
- package/src/council-engine/cli/llm-caller.ts +229 -0
- package/src/council-engine/cli/localStorage-shim.ts +119 -0
- package/src/council-engine/cli/node-platform.ts +68 -0
- package/src/council-engine/cli/run-council.ts +481 -0
- package/src/council-engine/cli/run-pipeline.ts +772 -0
- package/src/council-engine/cli/session-export.ts +153 -0
- package/src/council-engine/configs/councils/analysis.json +101 -0
- package/src/council-engine/configs/councils/code-planning.json +86 -0
- package/src/council-engine/configs/councils/coding.json +89 -0
- package/src/council-engine/configs/councils/debate.json +97 -0
- package/src/council-engine/configs/councils/solo-claude.json +34 -0
- package/src/council-engine/configs/councils/solo-gpt.json +34 -0
- package/src/council-engine/council/coding-orchestrator.ts +1205 -0
- package/src/council-engine/council/context-bootstrap.ts +147 -0
- package/src/council-engine/council/context-inspection.ts +42 -0
- package/src/council-engine/council/context-store.ts +763 -0
- package/src/council-engine/council/deliberation-orchestrator.ts +2762 -0
- package/src/council-engine/council/factory.ts +164 -0
- package/src/council-engine/council/index.ts +201 -0
- package/src/council-engine/council/ledger-store.ts +438 -0
- package/src/council-engine/council/prompts.ts +1689 -0
- package/src/council-engine/council/storage-cleanup.ts +164 -0
- package/src/council-engine/council/store.ts +1110 -0
- package/src/council-engine/council/synthesis.ts +291 -0
- package/src/council-engine/council/types.ts +845 -0
- package/src/council-engine/council/validation.ts +613 -0
- package/src/council-engine/pipeline/build-detect.ts +73 -0
- package/src/council-engine/pipeline/executor.ts +1048 -0
- package/src/council-engine/pipeline/index.ts +9 -0
- package/src/council-engine/pipeline/install-detect.ts +84 -0
- package/src/council-engine/pipeline/memory-store.ts +182 -0
- package/src/council-engine/pipeline/output-parsers.ts +146 -0
- package/src/council-engine/pipeline/run-output.ts +149 -0
- package/src/council-engine/pipeline/session-import.ts +177 -0
- package/src/council-engine/pipeline/store.ts +753 -0
- package/src/council-engine/pipeline/test-detect.ts +82 -0
- package/src/council-engine/pipeline/types.ts +401 -0
- package/src/council-engine/services/deliberationSummary.ts +114 -0
- package/src/council-engine/tsconfig.json +16 -0
- package/src/council-engine/types/mcp.ts +122 -0
- package/src/council-engine/utils/filterTools.ts +73 -0
- package/src/engine/apply.ts +238 -0
- package/src/engine/checkpoints.ts +237 -0
- package/src/engine/consultants.ts +347 -0
- package/src/engine/diff.ts +171 -0
- package/src/engine/errors.ts +102 -0
- package/src/engine/git-tools.ts +246 -0
- package/src/engine/hooks.ts +181 -0
- package/src/engine/loop-guard.ts +155 -0
- package/src/engine/permissions.ts +293 -0
- package/src/engine/pipeline.ts +376 -0
- package/src/engine/sub-agents.ts +133 -0
- package/src/engine/task-card.ts +185 -0
- package/src/engine/task-router.ts +256 -0
- package/src/engine/task-store.ts +86 -0
- package/src/engine/tools.ts +783 -0
- package/src/engine/verify.ts +111 -0
- package/src/mcp/client.ts +225 -0
- package/src/mcp/config.ts +120 -0
- package/src/mcp/tool-manager.ts +192 -0
- package/src/mcp/types.ts +61 -0
- package/src/providers/llm-caller.ts +943 -0
- package/src/providers/rate-limiter.ts +238 -0
- package/src/router/NOTES.md +28 -0
- package/src/router/collector.ts +474 -0
- package/src/router/embeddings.ts +286 -0
- package/src/router/index.ts +299 -0
- package/src/router/intent-router.ts +225 -0
- package/src/router/nn-router.ts +205 -0
- package/src/router/profiles.ts +309 -0
- package/src/router/registry.ts +565 -0
- package/src/router/rules.ts +274 -0
- package/src/router/train.py +408 -0
- package/src/session/store.ts +211 -0
- package/src/test-utils/mock-llm.ts +39 -0
- package/src/types.ts +322 -0
- package/src/web/manager.ts +311 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Council Factory
|
|
3
|
+
* Unified council creation from a CouncilSetup descriptor.
|
|
4
|
+
* Used by both standalone UI (CouncilLibrary) and pipeline executor.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
Council,
|
|
9
|
+
Persona,
|
|
10
|
+
DeliberationRoleAssignment,
|
|
11
|
+
SummaryMode,
|
|
12
|
+
} from './types';
|
|
13
|
+
import type { PipelinePersona } from '../pipeline/types';
|
|
14
|
+
import { councilStore } from './store';
|
|
15
|
+
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// CouncilSetup — canonical input for creating a council
|
|
18
|
+
// ============================================================================
|
|
19
|
+
|
|
20
|
+
export interface CouncilSetup {
|
|
21
|
+
name: string;
|
|
22
|
+
topic?: string;
|
|
23
|
+
/** Standing instructions — what this council should do (the task/directive) */
|
|
24
|
+
task?: string;
|
|
25
|
+
personas: PipelinePersona[];
|
|
26
|
+
maxRounds?: number; // Default: 2
|
|
27
|
+
maxRevisions?: number; // Default: 3
|
|
28
|
+
expectedOutput?: string;
|
|
29
|
+
decisionCriteria?: string[];
|
|
30
|
+
workingDirectory?: string;
|
|
31
|
+
directoryConstrained?: boolean; // Default: true
|
|
32
|
+
consultantExecution?: 'sequential' | 'parallel';
|
|
33
|
+
contextTokenBudget?: number; // Default: 80000
|
|
34
|
+
summaryMode?: SummaryMode; // Default: 'hybrid'
|
|
35
|
+
summarizeAfterRound?: number; // Default: 2
|
|
36
|
+
saveDeliberation?: boolean;
|
|
37
|
+
saveDeliberationMode?: 'full' | 'abbreviated';
|
|
38
|
+
maxWordsPerResponse?: number;
|
|
39
|
+
bootstrapContext?: boolean; // Default: true when workingDirectory is set
|
|
40
|
+
evolveContext?: boolean; // Default: false — append findings/results to context each phase
|
|
41
|
+
stepType?: 'council' | 'code_planning' | 'analysis' | 'agent' | 'coding' | 'review' | 'enrich';
|
|
42
|
+
testCommand?: string;
|
|
43
|
+
maxDebugCycles?: number;
|
|
44
|
+
maxReviewCycles?: number;
|
|
45
|
+
allowedServerIds?: string[];
|
|
46
|
+
pipelinePrefix?: string; // Prepended to name (e.g. '[Pipeline]')
|
|
47
|
+
pipelineId?: string; // Links council to creating pipeline
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// Default colors by role
|
|
52
|
+
// ============================================================================
|
|
53
|
+
|
|
54
|
+
const ROLE_COLORS: Record<string, string> = {
|
|
55
|
+
manager: '#6366f1',
|
|
56
|
+
worker: '#f59e0b',
|
|
57
|
+
reviewer: '#0ea5e9',
|
|
58
|
+
consultant: '#16a34a',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const ROLE_DEFAULT_TRAITS: Record<string, string[]> = {
|
|
62
|
+
manager: ['analytical', 'decisive'],
|
|
63
|
+
worker: ['thorough', 'detail-oriented'],
|
|
64
|
+
reviewer: ['critical', 'quality-focused'],
|
|
65
|
+
consultant: ['insightful', 'collaborative'],
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Factory Function
|
|
70
|
+
// ============================================================================
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Create a Council from a CouncilSetup descriptor.
|
|
74
|
+
*
|
|
75
|
+
* Handles:
|
|
76
|
+
* - Persona UUID generation + default colors/traits
|
|
77
|
+
* - Role assignment derivation from persona.role
|
|
78
|
+
* - councilStore.create() call with unified defaults
|
|
79
|
+
*/
|
|
80
|
+
export function createCouncilFromSetup(setup: CouncilSetup): Council {
|
|
81
|
+
const displayName = setup.pipelinePrefix
|
|
82
|
+
? `${setup.pipelinePrefix} ${setup.name}`
|
|
83
|
+
: setup.name;
|
|
84
|
+
|
|
85
|
+
// Convert PipelinePersona[] → Persona[]
|
|
86
|
+
const personas: Persona[] = setup.personas.map((p) => ({
|
|
87
|
+
id: crypto.randomUUID(),
|
|
88
|
+
name: p.name,
|
|
89
|
+
provider: p.provider,
|
|
90
|
+
model: p.model,
|
|
91
|
+
avatar: p.avatar,
|
|
92
|
+
color: p.color || ROLE_COLORS[p.role] || '#16a34a',
|
|
93
|
+
predisposition: {
|
|
94
|
+
systemPrompt: p.systemPrompt || `You are ${p.name}, a ${p.role} in this deliberation.`,
|
|
95
|
+
stance: p.stance || ('neutral' as const),
|
|
96
|
+
traits: p.traits && p.traits.length > 0
|
|
97
|
+
? p.traits
|
|
98
|
+
: ROLE_DEFAULT_TRAITS[p.role] || ['insightful', 'collaborative'],
|
|
99
|
+
interactionStyle: p.interactionStyle || ('build' as const),
|
|
100
|
+
domain: p.domain,
|
|
101
|
+
},
|
|
102
|
+
temperature: p.temperature ?? 0.7,
|
|
103
|
+
verbosity: p.verbosity || ('balanced' as const),
|
|
104
|
+
preferredDeliberationRole: p.role,
|
|
105
|
+
allowedServerIds: p.allowedServerIds,
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
// Derive role assignments from persona config
|
|
109
|
+
const roleAssignments: DeliberationRoleAssignment[] = setup.personas.map(
|
|
110
|
+
(p, i) => ({
|
|
111
|
+
personaId: personas[i].id,
|
|
112
|
+
role: p.role,
|
|
113
|
+
focusArea: p.focusArea,
|
|
114
|
+
stance: p.startingStance,
|
|
115
|
+
suppressPersona: p.suppressPersona ?? (p.role === 'manager' || p.role === 'worker' || p.role === 'reviewer'),
|
|
116
|
+
writePermissions: (p.role === 'worker' && p.toolAccess !== 'none') ? true : undefined,
|
|
117
|
+
toolAccess: p.toolAccess,
|
|
118
|
+
allowedServerIds: p.allowedServerIds,
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
// Resolve bootstrapContext default
|
|
123
|
+
const bootstrapContext = setup.bootstrapContext ?? (setup.workingDirectory ? true : false);
|
|
124
|
+
|
|
125
|
+
// Create council via store
|
|
126
|
+
const council = councilStore.create({
|
|
127
|
+
name: displayName,
|
|
128
|
+
topic: setup.topic || displayName,
|
|
129
|
+
personas,
|
|
130
|
+
orchestration: { mode: 'deliberation' },
|
|
131
|
+
pipelineId: setup.pipelineId,
|
|
132
|
+
deliberation: {
|
|
133
|
+
enabled: true,
|
|
134
|
+
roleAssignments,
|
|
135
|
+
minRounds: 1,
|
|
136
|
+
maxRounds: setup.maxRounds ?? 2,
|
|
137
|
+
maxRevisions: setup.maxRevisions ?? 3,
|
|
138
|
+
savedProblem: setup.task,
|
|
139
|
+
expectedOutput: setup.expectedOutput,
|
|
140
|
+
decisionCriteria: setup.decisionCriteria,
|
|
141
|
+
workingDirectory: setup.workingDirectory,
|
|
142
|
+
directoryConstrained: setup.directoryConstrained ?? true,
|
|
143
|
+
summaryMode: setup.summaryMode ?? 'hybrid',
|
|
144
|
+
summarizeAfterRound: setup.summarizeAfterRound ?? 2,
|
|
145
|
+
contextTokenBudget: setup.contextTokenBudget ?? 80000,
|
|
146
|
+
consultantErrorPolicy: 'retry',
|
|
147
|
+
maxRetries: 2,
|
|
148
|
+
requirePlan: false,
|
|
149
|
+
consultantExecution: setup.consultantExecution ?? 'sequential',
|
|
150
|
+
saveDeliberation: setup.saveDeliberation,
|
|
151
|
+
saveDeliberationMode: setup.saveDeliberationMode ?? 'full',
|
|
152
|
+
maxWordsPerResponse: setup.maxWordsPerResponse,
|
|
153
|
+
bootstrapContext,
|
|
154
|
+
evolveContext: setup.evolveContext ?? false,
|
|
155
|
+
stepType: setup.stepType,
|
|
156
|
+
testCommand: setup.testCommand,
|
|
157
|
+
maxDebugCycles: setup.maxDebugCycles ?? 5,
|
|
158
|
+
maxReviewCycles: setup.maxReviewCycles ?? 2,
|
|
159
|
+
allowedServerIds: setup.allowedServerIds,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return council;
|
|
164
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Council: Multi-Model Deliberation System
|
|
3
|
+
* Main export file
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Types
|
|
7
|
+
export * from './types';
|
|
8
|
+
|
|
9
|
+
// Validation
|
|
10
|
+
export * from './validation';
|
|
11
|
+
|
|
12
|
+
// Templates
|
|
13
|
+
export {
|
|
14
|
+
strategicTemplates,
|
|
15
|
+
technicalTemplates,
|
|
16
|
+
creativeTemplates,
|
|
17
|
+
domainTemplates,
|
|
18
|
+
allTemplates,
|
|
19
|
+
templatesByCategory,
|
|
20
|
+
templateCategories,
|
|
21
|
+
getTemplateByName,
|
|
22
|
+
getTemplatesByCategory,
|
|
23
|
+
createPersonaFromTemplate,
|
|
24
|
+
suggestedCombinations,
|
|
25
|
+
} from './templates';
|
|
26
|
+
|
|
27
|
+
// Store
|
|
28
|
+
export {
|
|
29
|
+
getAllCouncils,
|
|
30
|
+
getCouncil,
|
|
31
|
+
createCouncil,
|
|
32
|
+
updateCouncil,
|
|
33
|
+
deleteCouncil,
|
|
34
|
+
addPersona,
|
|
35
|
+
updatePersona,
|
|
36
|
+
removePersona,
|
|
37
|
+
setPersonaMuted,
|
|
38
|
+
addMessage,
|
|
39
|
+
getMessages,
|
|
40
|
+
setCouncilStatus,
|
|
41
|
+
setResolution,
|
|
42
|
+
updateCost,
|
|
43
|
+
searchCouncils,
|
|
44
|
+
getCouncilsByStatus,
|
|
45
|
+
getActiveCouncils,
|
|
46
|
+
getRecentCouncils,
|
|
47
|
+
exportCouncil,
|
|
48
|
+
importCouncil,
|
|
49
|
+
duplicateCouncil,
|
|
50
|
+
councilStore,
|
|
51
|
+
CouncilStore,
|
|
52
|
+
// Deliberation state operations
|
|
53
|
+
initializeDeliberationState,
|
|
54
|
+
updateDeliberationState,
|
|
55
|
+
setDeliberationPhase,
|
|
56
|
+
advanceDeliberationRound,
|
|
57
|
+
recordRoundSubmission,
|
|
58
|
+
isRoundComplete,
|
|
59
|
+
setRoleAssignments,
|
|
60
|
+
addPendingPatch,
|
|
61
|
+
removePendingPatch,
|
|
62
|
+
setRoundSummary,
|
|
63
|
+
setActiveContext,
|
|
64
|
+
setManagerEvaluation,
|
|
65
|
+
setFinalDecision,
|
|
66
|
+
setWorkDirective,
|
|
67
|
+
setCurrentOutput,
|
|
68
|
+
incrementRevisionCount,
|
|
69
|
+
addErrorToLog,
|
|
70
|
+
getPersonaByRole,
|
|
71
|
+
getRoleAssignment,
|
|
72
|
+
isDeliberationMode,
|
|
73
|
+
deleteCouncilWithData,
|
|
74
|
+
} from './store';
|
|
75
|
+
|
|
76
|
+
// Prompts
|
|
77
|
+
export {
|
|
78
|
+
buildPersonaSystemPrompt,
|
|
79
|
+
buildConversationContext,
|
|
80
|
+
buildSynthesisPrompt,
|
|
81
|
+
buildDebatePrompt,
|
|
82
|
+
buildSteelmanPrompt,
|
|
83
|
+
buildCommonGroundPrompt,
|
|
84
|
+
buildAskPrompt,
|
|
85
|
+
buildVotePrompt,
|
|
86
|
+
extractOpenQuestions,
|
|
87
|
+
// Deliberation prompts
|
|
88
|
+
getMinimalWorkerSystemPrompt,
|
|
89
|
+
buildManagerFramingPrompt,
|
|
90
|
+
buildManagerEvaluationPrompt,
|
|
91
|
+
buildManagerDecisionPrompt,
|
|
92
|
+
buildManagerForcedDecisionPrompt,
|
|
93
|
+
buildManagerPlanPrompt,
|
|
94
|
+
buildWorkDirectivePrompt,
|
|
95
|
+
buildManagerReviewPrompt,
|
|
96
|
+
buildManagerRoundSummaryPrompt,
|
|
97
|
+
buildIndependentAnalysisPrompt,
|
|
98
|
+
buildDeliberationResponsePrompt,
|
|
99
|
+
buildWorkerExecutionPrompt,
|
|
100
|
+
buildWorkerRevisionPrompt,
|
|
101
|
+
} from './prompts';
|
|
102
|
+
|
|
103
|
+
// Turn Strategies
|
|
104
|
+
export {
|
|
105
|
+
selectNextSpeaker,
|
|
106
|
+
isRoundComplete as isRoundCompleteForCouncil,
|
|
107
|
+
getUnheardPersonas,
|
|
108
|
+
selectDebateOpponents,
|
|
109
|
+
calculateRoundOrder,
|
|
110
|
+
} from './turn-strategies';
|
|
111
|
+
|
|
112
|
+
// Synthesis
|
|
113
|
+
export {
|
|
114
|
+
parseSynthesisResponse,
|
|
115
|
+
calculateConsensus,
|
|
116
|
+
extractKeyClaims,
|
|
117
|
+
findAgreements,
|
|
118
|
+
findTensions,
|
|
119
|
+
summarizePositions,
|
|
120
|
+
prepareSynthesisRequest,
|
|
121
|
+
quickConsensusCheck,
|
|
122
|
+
createRoundSummary,
|
|
123
|
+
} from './synthesis';
|
|
124
|
+
|
|
125
|
+
// Orchestrator
|
|
126
|
+
export {
|
|
127
|
+
CouncilOrchestrator,
|
|
128
|
+
createOrchestrator,
|
|
129
|
+
estimateTurnCost,
|
|
130
|
+
estimateRoundCost,
|
|
131
|
+
type LLMProvider,
|
|
132
|
+
type OrchestratorConfig,
|
|
133
|
+
} from './orchestrator';
|
|
134
|
+
|
|
135
|
+
// Ledger Store
|
|
136
|
+
export {
|
|
137
|
+
appendEntry,
|
|
138
|
+
getEntries,
|
|
139
|
+
getAllEntries,
|
|
140
|
+
getEntry,
|
|
141
|
+
getLatestOfType,
|
|
142
|
+
getEntriesForRound,
|
|
143
|
+
getEntriesByAuthor,
|
|
144
|
+
getLedgerTokenCount,
|
|
145
|
+
getManagerNotes,
|
|
146
|
+
formatEntriesForContext,
|
|
147
|
+
buildMechanicalSummary,
|
|
148
|
+
ledgerStore,
|
|
149
|
+
LedgerStore,
|
|
150
|
+
} from './ledger-store';
|
|
151
|
+
|
|
152
|
+
// Context Store
|
|
153
|
+
export {
|
|
154
|
+
// Context operations
|
|
155
|
+
getCurrentContext,
|
|
156
|
+
getContextHistory,
|
|
157
|
+
getContextVersion,
|
|
158
|
+
createInitialContext,
|
|
159
|
+
createContextVersion,
|
|
160
|
+
getContextDiff,
|
|
161
|
+
// Patch operations
|
|
162
|
+
getAllPatches,
|
|
163
|
+
getPendingPatches,
|
|
164
|
+
getPatch,
|
|
165
|
+
createPatch,
|
|
166
|
+
acceptPatch,
|
|
167
|
+
rejectPatch,
|
|
168
|
+
isPatchStale,
|
|
169
|
+
// Decision
|
|
170
|
+
getDecision,
|
|
171
|
+
createDecision,
|
|
172
|
+
// Plan
|
|
173
|
+
getPlan,
|
|
174
|
+
createPlan,
|
|
175
|
+
// Directive
|
|
176
|
+
getDirective,
|
|
177
|
+
createDirective,
|
|
178
|
+
// Output
|
|
179
|
+
getAllOutputs,
|
|
180
|
+
getLatestOutput,
|
|
181
|
+
getOutput,
|
|
182
|
+
createOutput,
|
|
183
|
+
createRevisionOutput,
|
|
184
|
+
// Cleanup
|
|
185
|
+
deleteAllArtifacts,
|
|
186
|
+
hasArtifacts,
|
|
187
|
+
// Class & instance
|
|
188
|
+
contextStore,
|
|
189
|
+
ContextStore,
|
|
190
|
+
} from './context-store';
|
|
191
|
+
|
|
192
|
+
// Factory
|
|
193
|
+
export {
|
|
194
|
+
createCouncilFromSetup,
|
|
195
|
+
type CouncilSetup,
|
|
196
|
+
} from './factory';
|
|
197
|
+
|
|
198
|
+
// Deliberation Orchestrator
|
|
199
|
+
export {
|
|
200
|
+
DeliberationOrchestrator,
|
|
201
|
+
} from './deliberation-orchestrator';
|