@csmedeiros/codemax 1.0.3 → 1.0.7
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 +4 -20
- package/launcher.js +28 -0
- package/package.json +15 -121
- package/LICENSE +0 -21
- package/dist/commands/cursorRules.d.ts +0 -15
- package/dist/commands/cursorRules.js +0 -118
- package/dist/commands/slashCommands.d.ts +0 -36
- package/dist/commands/slashCommands.js +0 -236
- package/dist/configuration/configManager.d.ts +0 -32
- package/dist/configuration/configManager.js +0 -71
- package/dist/configuration/modelContextWindows.d.ts +0 -3
- package/dist/configuration/modelContextWindows.js +0 -13
- package/dist/conversation/agentGraph.d.ts +0 -203
- package/dist/conversation/agentGraph.js +0 -433
- package/dist/conversation/agentTurn.d.ts +0 -40
- package/dist/conversation/agentTurn.js +0 -252
- package/dist/conversation/chatHistory.d.ts +0 -24
- package/dist/conversation/chatHistory.js +0 -251
- package/dist/conversation/compactionUtils.d.ts +0 -17
- package/dist/conversation/compactionUtils.js +0 -57
- package/dist/conversation/prompts/planPrompt.d.ts +0 -1
- package/dist/conversation/prompts/planPrompt.js +0 -12
- package/dist/conversation/prompts/systemPrompt.d.ts +0 -29
- package/dist/conversation/prompts/systemPrompt.js +0 -149
- package/dist/entry/cli.d.ts +0 -2
- package/dist/entry/cli.js +0 -24
- package/dist/observability/langfuseTracing.d.ts +0 -5
- package/dist/observability/langfuseTracing.js +0 -76
- package/dist/shared/types.d.ts +0 -25
- package/dist/shared/types.js +0 -1
- package/dist/terminal/app.d.ts +0 -2
- package/dist/terminal/app.js +0 -1236
- package/dist/terminal/components.d.ts +0 -18
- package/dist/terminal/components.js +0 -43
- package/dist/terminal/markdown.d.ts +0 -4
- package/dist/terminal/markdown.js +0 -47
- package/dist/terminal/screens/compactionSettings.d.ts +0 -6
- package/dist/terminal/screens/compactionSettings.js +0 -66
- package/dist/terminal/screens/modelSettings.d.ts +0 -10
- package/dist/terminal/screens/modelSettings.js +0 -76
- package/dist/terminal/textField.d.ts +0 -7
- package/dist/terminal/textField.js +0 -136
- package/dist/terminal/theme.d.ts +0 -23
- package/dist/terminal/theme.js +0 -23
- package/dist/tooling/mcpConfig.d.ts +0 -40
- package/dist/tooling/mcpConfig.js +0 -49
- package/dist/tooling/planControlChannel.d.ts +0 -2
- package/dist/tooling/planControlChannel.js +0 -21
- package/dist/tooling/toolConfig.d.ts +0 -42
- package/dist/tooling/toolConfig.js +0 -138
- package/dist/tooling/toolUiCallback.d.ts +0 -21
- package/dist/tooling/toolUiCallback.js +0 -268
- package/dist/tooling/tools.d.ts +0 -216
- package/dist/tooling/tools.js +0 -614
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* System prompts for the LangChain agent.
|
|
3
|
-
*
|
|
4
|
-
* Customize these prompts to change your agent's behavior and personality.
|
|
5
|
-
*/
|
|
6
|
-
import { HumanMessage } from '@langchain/core/messages';
|
|
7
|
-
/**
|
|
8
|
-
* Marks ephemeral per-turn system messages that carry the host date/time; stripped before persisting thread history.
|
|
9
|
-
*/
|
|
10
|
-
export const CODEMAX_TURN_DATETIME_MARKER = '<!--codemax-datetime-context-->';
|
|
11
|
-
function stringifyMessageContent(content) {
|
|
12
|
-
if (typeof content === 'string')
|
|
13
|
-
return content;
|
|
14
|
-
if (Array.isArray(content)) {
|
|
15
|
-
return content
|
|
16
|
-
.map(block => {
|
|
17
|
-
if (typeof block === 'string')
|
|
18
|
-
return block;
|
|
19
|
-
if (block && typeof block === 'object' && 'text' in block) {
|
|
20
|
-
return String(block.text);
|
|
21
|
-
}
|
|
22
|
-
return '';
|
|
23
|
-
})
|
|
24
|
-
.join('\n');
|
|
25
|
-
}
|
|
26
|
-
return '';
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Current local date/time using the host OS time zone and locale (via Intl).
|
|
30
|
-
*/
|
|
31
|
-
export function formatLocalDateTimeContext() {
|
|
32
|
-
const resolved = Intl.DateTimeFormat().resolvedOptions();
|
|
33
|
-
const timeZone = resolved.timeZone ?? 'UTC';
|
|
34
|
-
const locale = resolved.locale;
|
|
35
|
-
const now = new Date();
|
|
36
|
-
const localLine = new Intl.DateTimeFormat(locale, {
|
|
37
|
-
dateStyle: 'full',
|
|
38
|
-
timeStyle: 'long',
|
|
39
|
-
timeZone,
|
|
40
|
-
}).format(now);
|
|
41
|
-
return [
|
|
42
|
-
`Host time zone (IANA): ${timeZone}`,
|
|
43
|
-
`Current local date and time: ${localLine}`,
|
|
44
|
-
`Instant (UTC, ISO 8601): ${now.toISOString()}`,
|
|
45
|
-
].join('\n');
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Content for a single-turn HumanMessage injected before each agent invocation.
|
|
49
|
-
* Using a user message (not system) keeps the system prompt stable for prompt caching.
|
|
50
|
-
*/
|
|
51
|
-
export function buildCodemaxTurnDatetimeUserContent() {
|
|
52
|
-
return `${CODEMAX_TURN_DATETIME_MARKER}\n# Current date and time (host system)\n${formatLocalDateTimeContext()}`;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Removes the ephemeral datetime user message from graph output so REPL history does not accumulate it.
|
|
56
|
-
*/
|
|
57
|
-
export function stripCodemaxTurnDatetimeFromMessages(messages) {
|
|
58
|
-
const idx = messages.findIndex(m => {
|
|
59
|
-
if (!(m instanceof HumanMessage))
|
|
60
|
-
return false;
|
|
61
|
-
return stringifyMessageContent(m.content).startsWith(CODEMAX_TURN_DATETIME_MARKER);
|
|
62
|
-
});
|
|
63
|
-
if (idx === -1)
|
|
64
|
-
return messages;
|
|
65
|
-
return [...messages.slice(0, idx), ...messages.slice(idx + 1)];
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The main system prompt that defines the agent's behavior.
|
|
69
|
-
* This is passed to createAgent as the systemPrompt parameter.
|
|
70
|
-
*/
|
|
71
|
-
export const COMPACT_SUMMARY_PROMPT = `You are compacting a long agentic coding session. Produce a detailed summary preserving:
|
|
72
|
-
- The user's overarching goals and the current task being worked on.
|
|
73
|
-
- All file paths read, written, or modified and their purposes.
|
|
74
|
-
- Key decisions and their rationale.
|
|
75
|
-
- Current todo state and in-progress work.
|
|
76
|
-
- Important tool results (errors, search hits, file contents that informed decisions).
|
|
77
|
-
- Open questions and unresolved blockers.
|
|
78
|
-
|
|
79
|
-
Be specific — preserve exact filenames, function names, identifiers, command outputs, and error messages. Format as structured Markdown with clear sections. Do not omit details that would be needed to continue the work seamlessly.`;
|
|
80
|
-
export const SYSTEM_PROMPT = `
|
|
81
|
-
<role>
|
|
82
|
-
|
|
83
|
-
You are CodeMax, the next-generation code agent.
|
|
84
|
-
You are responsible for solving software development tasks by generating code, explanations, and reasoning steps.
|
|
85
|
-
|
|
86
|
-
</role>
|
|
87
|
-
|
|
88
|
-
<general_instructions>
|
|
89
|
-
|
|
90
|
-
- When the conversation includes a system message with the host's current local date and time (and time zone), use it for anything that depends on "now", "today", or scheduling.
|
|
91
|
-
- You will receive a task and you will need to solve it.
|
|
92
|
-
- The first step is to understand the task and the context by reading the codebase documentation and codebase, and write a TO-DO list of the steps you need to take to solve the task using the 'todoTool'.
|
|
93
|
-
- As you progress through the task, you must update the status of the items in the TO-DO list using the 'todoTool'.
|
|
94
|
-
|
|
95
|
-
</general_instructions>
|
|
96
|
-
|
|
97
|
-
<rules>
|
|
98
|
-
|
|
99
|
-
When rules are injected into this conversation, you MUST follow them strictly and without exception.
|
|
100
|
-
Rules override your default behavior. They are not suggestions — treat them as hard constraints.
|
|
101
|
-
If a rule conflicts with a general instruction, the rule wins.
|
|
102
|
-
|
|
103
|
-
</rules>
|
|
104
|
-
|
|
105
|
-
<file_reading>
|
|
106
|
-
|
|
107
|
-
- NEVER read an entire file unless you are certain you need every line.
|
|
108
|
-
- Always use 'startLine' and 'endLine' to read only the portion you need.
|
|
109
|
-
- If you do not know how many lines a file has or where the relevant section is, start by reading lines 1–20 to orient yourself, then read further ranges as needed.
|
|
110
|
-
- Prefer multiple small reads over one large read.
|
|
111
|
-
|
|
112
|
-
</file_reading>
|
|
113
|
-
|
|
114
|
-
<todo_tool>
|
|
115
|
-
- Use the 'todoTool' to manage your task list.
|
|
116
|
-
- Actions: 'add', 'update', 'remove', 'list'.
|
|
117
|
-
- Statuses: 'pending', 'in_progress', 'completed'.
|
|
118
|
-
- When starting a task, 'add' all the steps you identified.
|
|
119
|
-
- When you start working on a step, 'update' its status to 'in_progress'.
|
|
120
|
-
- When you finish a step, 'update' its status to 'completed'.
|
|
121
|
-
</todo_tool>
|
|
122
|
-
|
|
123
|
-
<subagents>
|
|
124
|
-
|
|
125
|
-
- You are able to use subagents to help you solve tasks.
|
|
126
|
-
- You can delegate tasks for subagents to solve.
|
|
127
|
-
- For delegation, you must use the 'subagent' tool.
|
|
128
|
-
- The subagent tool will return a report of the task completion.
|
|
129
|
-
- The report will be a JSON file with the following properties:
|
|
130
|
-
- 'status': 'success' or 'error'
|
|
131
|
-
- 'message': a short description of the result
|
|
132
|
-
- 'data': the data returned by the subagent
|
|
133
|
-
- 'files': a list of dictionaries with the following properties:
|
|
134
|
-
- 'path': the path of the file
|
|
135
|
-
- 'content': a short description of what he did in the file
|
|
136
|
-
</subagents>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<response_format>
|
|
141
|
-
|
|
142
|
-
- You must NEVER answer with emojis.
|
|
143
|
-
- You must ALWAYS answer with markdown headings and markdown bullet points.
|
|
144
|
-
- You must ALWAYS answer with a clear and concise response.
|
|
145
|
-
- Your answers must be ALWAYS about what the user wants to know about or what you have done in your work.
|
|
146
|
-
- NEVER answer with unnecessary facts or anything that doesn't relate to the user's request, your answer, or what the user wants to know.
|
|
147
|
-
|
|
148
|
-
</response_format>
|
|
149
|
-
`;
|
package/dist/entry/cli.d.ts
DELETED
package/dist/entry/cli.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render } from 'ink';
|
|
4
|
-
import meow from 'meow';
|
|
5
|
-
import App from '../terminal/app.js';
|
|
6
|
-
import { shutdownLangfuseTracing } from '../observability/langfuseTracing.js';
|
|
7
|
-
for (const sig of ['SIGINT', 'SIGTERM', 'exit']) {
|
|
8
|
-
process.on(sig, () => {
|
|
9
|
-
void shutdownLangfuseTracing();
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
const cli = meow(`
|
|
13
|
-
Usage
|
|
14
|
-
$ codemax
|
|
15
|
-
|
|
16
|
-
Examples
|
|
17
|
-
$ codemax
|
|
18
|
-
`, {
|
|
19
|
-
importMeta: import.meta,
|
|
20
|
-
flags: {},
|
|
21
|
-
});
|
|
22
|
-
// `cli` is parsed to keep a place for future flags while we iterate.
|
|
23
|
-
void cli;
|
|
24
|
-
render(React.createElement(App, null));
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
2
|
-
export declare function initLangfuseTracing(): boolean;
|
|
3
|
-
export declare function shutdownLangfuseTracing(): Promise<void>;
|
|
4
|
-
export declare function getLangfuseCallbacksForTurn(sessionId: string): BaseCallbackHandler[];
|
|
5
|
-
export declare function createCodemaxSessionId(prefix: string): string;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
2
|
-
import { LangfuseSpanProcessor } from '@langfuse/otel';
|
|
3
|
-
import { CallbackHandler } from '@langfuse/langchain';
|
|
4
|
-
import { randomUUID } from 'node:crypto';
|
|
5
|
-
let tracingEnabled = false;
|
|
6
|
-
let otelSdk;
|
|
7
|
-
function langfuseEnvConfigured() {
|
|
8
|
-
const sk = process.env['LANGFUSE_SECRET_KEY']?.trim();
|
|
9
|
-
const pk = process.env['LANGFUSE_PUBLIC_KEY']?.trim();
|
|
10
|
-
return Boolean(sk && pk);
|
|
11
|
-
}
|
|
12
|
-
// Guards all serialized-argument callbacks against undefined — some non-OpenAI
|
|
13
|
-
// models omit the first argument, causing `.id.at(-1)` / `.name` to throw.
|
|
14
|
-
class SafeCallbackHandler extends CallbackHandler {
|
|
15
|
-
async handleToolStart(tool, input, runId, parentRunId, tags, metadata, runName) {
|
|
16
|
-
if (!tool)
|
|
17
|
-
return;
|
|
18
|
-
return super.handleToolStart(tool, input, runId, parentRunId, tags, metadata, runName);
|
|
19
|
-
}
|
|
20
|
-
async handleChainStart(chain, inputs, runId, parentRunId, tags, metadata, runType, runName) {
|
|
21
|
-
if (!chain)
|
|
22
|
-
return;
|
|
23
|
-
return super.handleChainStart(chain, inputs, runId, parentRunId, tags, metadata, runType, runName);
|
|
24
|
-
}
|
|
25
|
-
async handleLLMStart(llm, prompts, runId, parentRunId, extraParams, tags, metadata, runName) {
|
|
26
|
-
if (!llm)
|
|
27
|
-
return;
|
|
28
|
-
return super.handleLLMStart(llm, prompts, runId, parentRunId, extraParams, tags, metadata, runName);
|
|
29
|
-
}
|
|
30
|
-
async handleChatModelStart(llm, messages, runId, parentRunId, extraParams, tags, metadata, runName) {
|
|
31
|
-
if (!llm)
|
|
32
|
-
return;
|
|
33
|
-
return super.handleChatModelStart(llm, messages, runId, parentRunId, extraParams, tags, metadata, runName);
|
|
34
|
-
}
|
|
35
|
-
// handleGenerationStart is an internal method called by handleChatModelStart /
|
|
36
|
-
// handleLLMStart — guard it directly so async re-entrant calls can't crash either.
|
|
37
|
-
async handleGenerationStart(llm, messages, runId, parentRunId, extraParams, tags, metadata, runName) {
|
|
38
|
-
if (!llm)
|
|
39
|
-
return;
|
|
40
|
-
// handleGenerationStart is not declared on the base type — call via prototype
|
|
41
|
-
const proto = Object.getPrototypeOf(Object.getPrototypeOf(this));
|
|
42
|
-
return proto.handleGenerationStart.call(this, llm, messages, runId, parentRunId, extraParams, tags, metadata, runName);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export function initLangfuseTracing() {
|
|
46
|
-
if (!langfuseEnvConfigured())
|
|
47
|
-
return false;
|
|
48
|
-
otelSdk = new NodeSDK({
|
|
49
|
-
spanProcessors: [new LangfuseSpanProcessor()],
|
|
50
|
-
});
|
|
51
|
-
otelSdk.start();
|
|
52
|
-
tracingEnabled = true;
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
export async function shutdownLangfuseTracing() {
|
|
56
|
-
if (otelSdk) {
|
|
57
|
-
await otelSdk.shutdown();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export function getLangfuseCallbacksForTurn(sessionId) {
|
|
61
|
-
if (!tracingEnabled)
|
|
62
|
-
return [];
|
|
63
|
-
const userId = process.env['CODEMAX_USER_ID']?.trim() ||
|
|
64
|
-
process.env['LANGFUSE_USER_ID']?.trim();
|
|
65
|
-
return [
|
|
66
|
-
new SafeCallbackHandler({
|
|
67
|
-
sessionId,
|
|
68
|
-
...(userId ? { userId } : {}),
|
|
69
|
-
tags: ['codemax', 'cli'],
|
|
70
|
-
traceMetadata: { app: 'codemax' },
|
|
71
|
-
}),
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
|
-
export function createCodemaxSessionId(prefix) {
|
|
75
|
-
return `${prefix}-${randomUUID()}`;
|
|
76
|
-
}
|
package/dist/shared/types.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type TranscriptItem = {
|
|
2
|
-
id: string;
|
|
3
|
-
role: 'user';
|
|
4
|
-
text: string;
|
|
5
|
-
} | {
|
|
6
|
-
id: string;
|
|
7
|
-
role: 'assistant';
|
|
8
|
-
text: string;
|
|
9
|
-
timestamp: string;
|
|
10
|
-
} | {
|
|
11
|
-
id: string;
|
|
12
|
-
role: 'system';
|
|
13
|
-
text: string;
|
|
14
|
-
} | {
|
|
15
|
-
id: string;
|
|
16
|
-
role: 'tool';
|
|
17
|
-
text: string;
|
|
18
|
-
kind: 'start' | 'end' | 'error' | 'approval';
|
|
19
|
-
toolName: string;
|
|
20
|
-
toolCall?: any;
|
|
21
|
-
} | {
|
|
22
|
-
id: string;
|
|
23
|
-
role: 'meta';
|
|
24
|
-
text: string;
|
|
25
|
-
};
|
package/dist/shared/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/terminal/app.d.ts
DELETED