@codemieai/code 0.0.33 → 0.0.34
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 +73 -7
- package/bin/codemie-opencode.js +11 -0
- package/dist/agents/codemie-code/agent.d.ts +17 -1
- package/dist/agents/codemie-code/agent.d.ts.map +1 -1
- package/dist/agents/codemie-code/agent.js +62 -3
- package/dist/agents/codemie-code/agent.js.map +1 -1
- package/dist/agents/codemie-code/index.d.ts +1 -0
- package/dist/agents/codemie-code/index.d.ts.map +1 -1
- package/dist/agents/codemie-code/index.js +28 -2
- package/dist/agents/codemie-code/index.js.map +1 -1
- package/dist/agents/codemie-code/prompts.d.ts +12 -3
- package/dist/agents/codemie-code/prompts.d.ts.map +1 -1
- package/dist/agents/codemie-code/prompts.js +25 -5
- package/dist/agents/codemie-code/prompts.js.map +1 -1
- package/dist/agents/codemie-code/types.d.ts +3 -0
- package/dist/agents/codemie-code/types.d.ts.map +1 -1
- package/dist/agents/codemie-code/types.js.map +1 -1
- package/dist/agents/core/AgentCLI.d.ts.map +1 -1
- package/dist/agents/core/AgentCLI.js +3 -1
- package/dist/agents/core/AgentCLI.js.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.js +33 -0
- package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
- package/dist/agents/core/session/BaseSessionAdapter.d.ts +25 -0
- package/dist/agents/core/session/BaseSessionAdapter.d.ts.map +1 -1
- package/dist/agents/core/session/discovery-types.d.ts +53 -0
- package/dist/agents/core/session/discovery-types.d.ts.map +1 -0
- package/dist/agents/core/session/discovery-types.js +8 -0
- package/dist/agents/core/session/discovery-types.js.map +1 -0
- package/dist/agents/core/types.d.ts +45 -0
- package/dist/agents/core/types.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude.plugin.d.ts +44 -1
- package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude.plugin.js +214 -0
- package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
- package/dist/agents/plugins/claude/plugin/README.md +40 -2
- package/dist/agents/plugins/claude/plugin/claude-templates/README.md +5 -5
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/CLAUDE.md.template +177 -436
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/code-review-agent-template.md.template +49 -82
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/refactor-cleaner-agent.md.template +337 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/solution-architect-agent.md.template +129 -419
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/unit-tester-agent.md.template +146 -693
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/api/api-patterns.md.template +110 -138
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/architecture.md.template +197 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/data/database-patterns.md.template +171 -91
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/development/development-practices.md.template +219 -131
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/security/security-practices.md.template +223 -98
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/standards/code-quality.md.template +131 -95
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/testing/testing-patterns.md.template +247 -75
- package/dist/agents/plugins/claude/plugin/commands/README.md +133 -0
- package/dist/agents/plugins/claude/plugin/commands/codemie-init.md +336 -544
- package/dist/agents/plugins/claude/plugin/commands/codemie-subagents.md +232 -503
- package/dist/agents/plugins/claude/plugin/commands/memory-add.md +311 -30
- package/dist/agents/plugins/claude/plugin/commands/memory-refresh.md +218 -39
- package/dist/agents/plugins/gemini/gemini.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/gemini/gemini.plugin.js +0 -3
- package/dist/agents/plugins/gemini/gemini.plugin.js.map +1 -1
- package/dist/agents/plugins/opencode/index.d.ts +8 -0
- package/dist/agents/plugins/opencode/index.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/index.js +12 -0
- package/dist/agents/plugins/opencode/index.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode-message-types.d.ts +207 -0
- package/dist/agents/plugins/opencode/opencode-message-types.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode-message-types.js +59 -0
- package/dist/agents/plugins/opencode/opencode-message-types.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.d.ts +65 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.js +184 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.paths.d.ts +62 -0
- package/dist/agents/plugins/opencode/opencode.paths.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.paths.js +148 -0
- package/dist/agents/plugins/opencode/opencode.paths.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.plugin.d.ts +35 -0
- package/dist/agents/plugins/opencode/opencode.plugin.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.plugin.js +338 -0
- package/dist/agents/plugins/opencode/opencode.plugin.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.session.d.ts +77 -0
- package/dist/agents/plugins/opencode/opencode.session.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.session.js +424 -0
- package/dist/agents/plugins/opencode/opencode.session.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts +25 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.js +96 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.js.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts +30 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js +116 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts +102 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js +584 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js.map +1 -0
- package/dist/agents/registry.d.ts.map +1 -1
- package/dist/agents/registry.js +2 -0
- package/dist/agents/registry.js.map +1 -1
- package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts +5 -0
- package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts.map +1 -1
- package/dist/cli/commands/doctor/checks/AgentsCheck.js +29 -0
- package/dist/cli/commands/doctor/checks/AgentsCheck.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +86 -7
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/opencode-metrics.d.ts +13 -0
- package/dist/cli/commands/opencode-metrics.d.ts.map +1 -0
- package/dist/cli/commands/opencode-metrics.js +200 -0
- package/dist/cli/commands/opencode-metrics.js.map +1 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +113 -0
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/skill.d.ts +6 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +196 -0
- package/dist/cli/commands/skill.js.map +1 -0
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +34 -6
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/migrations/003-remove-hooks-node.migration.d.ts +22 -0
- package/dist/migrations/003-remove-hooks-node.migration.d.ts.map +1 -0
- package/dist/migrations/003-remove-hooks-node.migration.js +103 -0
- package/dist/migrations/003-remove-hooks-node.migration.js.map +1 -0
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +1 -1
- package/dist/migrations/index.js.map +1 -1
- package/dist/providers/plugins/sso/sso.http-client.js +2 -2
- package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.js +14 -10
- package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
- package/dist/skills/core/SkillDiscovery.d.ts +83 -0
- package/dist/skills/core/SkillDiscovery.d.ts.map +1 -0
- package/dist/skills/core/SkillDiscovery.js +237 -0
- package/dist/skills/core/SkillDiscovery.js.map +1 -0
- package/dist/skills/core/SkillManager.d.ts +86 -0
- package/dist/skills/core/SkillManager.d.ts.map +1 -0
- package/dist/skills/core/SkillManager.js +155 -0
- package/dist/skills/core/SkillManager.js.map +1 -0
- package/dist/skills/core/types.d.ts +120 -0
- package/dist/skills/core/types.d.ts.map +1 -0
- package/dist/skills/core/types.js +20 -0
- package/dist/skills/core/types.js.map +1 -0
- package/dist/skills/index.d.ts +12 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +12 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/utils/content-loader.d.ts +25 -0
- package/dist/skills/utils/content-loader.d.ts.map +1 -0
- package/dist/skills/utils/content-loader.js +161 -0
- package/dist/skills/utils/content-loader.js.map +1 -0
- package/dist/skills/utils/frontmatter.d.ts +60 -0
- package/dist/skills/utils/frontmatter.d.ts.map +1 -0
- package/dist/skills/utils/frontmatter.js +114 -0
- package/dist/skills/utils/frontmatter.js.map +1 -0
- package/dist/skills/utils/pattern-matcher.d.ts +60 -0
- package/dist/skills/utils/pattern-matcher.d.ts.map +1 -0
- package/dist/skills/utils/pattern-matcher.js +97 -0
- package/dist/skills/utils/pattern-matcher.js.map +1 -0
- package/dist/utils/installation-detector.d.ts +22 -0
- package/dist/utils/installation-detector.d.ts.map +1 -0
- package/dist/utils/installation-detector.js +49 -0
- package/dist/utils/installation-detector.js.map +1 -0
- package/dist/utils/native-installer.d.ts +49 -0
- package/dist/utils/native-installer.d.ts.map +1 -0
- package/dist/utils/native-installer.js +194 -0
- package/dist/utils/native-installer.js.map +1 -0
- package/dist/utils/version-utils.d.ts +50 -0
- package/dist/utils/version-utils.d.ts.map +1 -0
- package/dist/utils/version-utils.js +92 -0
- package/dist/utils/version-utils.js.map +1 -0
- package/package.json +5 -2
- package/scripts/copy-mr-skill-to-global.ts +252 -0
- package/scripts/demo-hooks.sh +125 -0
- package/scripts/test-hooks.sh +196 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/INDEX.md +0 -205
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/TEMPLATE_SIZES.md +0 -74
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/layered-architecture.md.template +0 -143
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/project-structure.md.template +0 -127
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isTextPart, isToolPart, isFilePart, isReasoningPart } from '../../opencode-message-types.js';
|
|
2
|
+
import { logger } from '../../../../../utils/logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* OpenCode Conversations Processor
|
|
5
|
+
*
|
|
6
|
+
* Normalizes OpenCode messages and parts into unified conversation format.
|
|
7
|
+
* Implements SessionProcessor interface for processor chain.
|
|
8
|
+
*/
|
|
9
|
+
export class OpenCodeConversationsProcessor {
|
|
10
|
+
name = 'opencode-conversations';
|
|
11
|
+
priority = 2; // Run after metrics
|
|
12
|
+
/**
|
|
13
|
+
* Check if session has data to process
|
|
14
|
+
*/
|
|
15
|
+
shouldProcess(session) {
|
|
16
|
+
return session.messages.length > 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Process session to normalize conversations
|
|
20
|
+
*/
|
|
21
|
+
async process(session, _context) {
|
|
22
|
+
try {
|
|
23
|
+
const messages = session.messages;
|
|
24
|
+
const normalizedMessages = [];
|
|
25
|
+
for (const message of messages) {
|
|
26
|
+
// UPDATED (GPT-5.9): Use time.created (numeric) instead of createdAt (string)
|
|
27
|
+
// For full implementation, parts would be loaded from part/{messageId}/*.json
|
|
28
|
+
// For now, create basic normalized message from message data
|
|
29
|
+
const normalized = {
|
|
30
|
+
id: message.id,
|
|
31
|
+
role: message.role,
|
|
32
|
+
content: '', // Would be populated from text parts (AC-EXT-1)
|
|
33
|
+
// UPDATED (GPT-5.9): Convert numeric timestamp to ISO string
|
|
34
|
+
timestamp: message.time?.created
|
|
35
|
+
? new Date(message.time.created).toISOString()
|
|
36
|
+
: new Date().toISOString(),
|
|
37
|
+
// UPDATED (GPT-5.9): modelID is on assistant messages only
|
|
38
|
+
model: message.role === 'assistant'
|
|
39
|
+
? message.modelID
|
|
40
|
+
: undefined,
|
|
41
|
+
agent: message.role === 'assistant'
|
|
42
|
+
? message.agent
|
|
43
|
+
: undefined
|
|
44
|
+
};
|
|
45
|
+
normalizedMessages.push(normalized);
|
|
46
|
+
}
|
|
47
|
+
logger.debug(`[opencode-conversations] Normalized ${normalizedMessages.length} messages`);
|
|
48
|
+
return {
|
|
49
|
+
success: true,
|
|
50
|
+
message: `Normalized ${normalizedMessages.length} messages`,
|
|
51
|
+
metadata: {
|
|
52
|
+
recordsProcessed: normalizedMessages.length,
|
|
53
|
+
userMessages: normalizedMessages.filter(m => m.role === 'user').length,
|
|
54
|
+
assistantMessages: normalizedMessages.filter(m => m.role === 'assistant').length
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
60
|
+
logger.error(`[opencode-conversations] Processing failed:`, error);
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
message: `Conversations processing failed: ${errorMessage}`
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Process parts for a message (helper for full implementation)
|
|
69
|
+
* Parts are loaded from part/{messageID}/*.json
|
|
70
|
+
*
|
|
71
|
+
* UPDATED (GPT-5.9): Use new part schema:
|
|
72
|
+
* - Tool parts: callID, tool, state.input, state (not toolName, toolInput, toolOutput)
|
|
73
|
+
* - File parts: mime, url, source, filename (not filePath, content)
|
|
74
|
+
*/
|
|
75
|
+
processParts(parts) {
|
|
76
|
+
const textParts = [];
|
|
77
|
+
const toolUse = [];
|
|
78
|
+
const fileReferences = [];
|
|
79
|
+
const thinkingParts = [];
|
|
80
|
+
for (const part of parts) {
|
|
81
|
+
// Use type guards for safe narrowing
|
|
82
|
+
if (isTextPart(part)) {
|
|
83
|
+
textParts.push(part.text);
|
|
84
|
+
}
|
|
85
|
+
else if (isToolPart(part)) {
|
|
86
|
+
// UPDATED (GPT-5.9): New tool part schema
|
|
87
|
+
toolUse.push({
|
|
88
|
+
name: part.tool, // Was: part.toolName
|
|
89
|
+
input: part.state.input || {}, // Input is inside state
|
|
90
|
+
output: part.state?.output // Was: part.toolOutput
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else if (isFilePart(part)) {
|
|
94
|
+
// UPDATED (GPT-5.9): New file part schema
|
|
95
|
+
// Use url or construct reference from filename
|
|
96
|
+
if (part.url) {
|
|
97
|
+
fileReferences.push(part.url);
|
|
98
|
+
}
|
|
99
|
+
else if (part.filename) {
|
|
100
|
+
fileReferences.push(part.filename);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (isReasoningPart(part)) {
|
|
104
|
+
thinkingParts.push(part.text);
|
|
105
|
+
}
|
|
106
|
+
// step-finish parts are skipped (metadata only - tokens/cost handled by metrics)
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
content: textParts.join('\n'),
|
|
110
|
+
toolUse: toolUse.length > 0 ? toolUse : undefined,
|
|
111
|
+
fileReferences: fileReferences.length > 0 ? fileReferences : [],
|
|
112
|
+
thinking: thinkingParts.join('\n')
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=opencode.conversations-processor.js.map
|
package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode.conversations-processor.js","sourceRoot":"","sources":["../../../../../../src/agents/plugins/opencode/session/processors/opencode.conversations-processor.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAyBxD;;;;;GAKG;AACH,MAAM,OAAO,8BAA8B;IAChC,IAAI,GAAG,wBAAwB,CAAC;IAChC,QAAQ,GAAG,CAAC,CAAC,CAAE,oBAAoB;IAE5C;;OAEG;IACH,aAAa,CAAC,OAAsB;QAClC,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,OAAsB,EAAE,QAA2B;QAC/D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,OAAO,CAAC,QAA6B,CAAC;YACvD,MAAM,kBAAkB,GAAwB,EAAE,CAAC;YAEnD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,8EAA8E;gBAC9E,8EAA8E;gBAC9E,6DAA6D;gBAC7D,MAAM,UAAU,GAAsB;oBACpC,EAAE,EAAE,OAAO,CAAC,EAAE;oBACd,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,OAAO,EAAE,EAAE,EAAG,gDAAgD;oBAC9D,6DAA6D;oBAC7D,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO;wBAC9B,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE;wBAC9C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C,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;YACjD,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;YAC/D,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;SACnC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Metrics Processor
|
|
3
|
+
*
|
|
4
|
+
* Transforms OpenCode session messages into MetricDelta records and writes
|
|
5
|
+
* them to JSONL for eventual sync to CodeMie API.
|
|
6
|
+
*
|
|
7
|
+
* Per tech spec "Fix OpenCode Metrics Sync":
|
|
8
|
+
* - Loads parts from storage/part/{messageID}/
|
|
9
|
+
* - Extracts tool usage, file operations, user prompts
|
|
10
|
+
* - Creates MetricDelta records per assistant message (ADR-16)
|
|
11
|
+
* - Writes to JSONL via MetricsWriter with status: 'pending'
|
|
12
|
+
* - Implements deduplication to prevent duplicate deltas
|
|
13
|
+
*/
|
|
14
|
+
import type { SessionProcessor, ProcessingContext, ProcessingResult } from '../../../../core/session/BaseProcessor.js';
|
|
15
|
+
import type { ParsedSession } from '../../../../core/session/BaseSessionAdapter.js';
|
|
16
|
+
/**
|
|
17
|
+
* OpenCode Metrics Processor
|
|
18
|
+
*
|
|
19
|
+
* Aggregates token usage, extracts tool/file metrics from parts,
|
|
20
|
+
* and writes MetricDelta records to JSONL.
|
|
21
|
+
*/
|
|
22
|
+
export declare class OpenCodeMetricsProcessor implements SessionProcessor {
|
|
23
|
+
readonly name = "opencode-metrics";
|
|
24
|
+
readonly priority = 1;
|
|
25
|
+
private readonly cacheDir;
|
|
26
|
+
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Check if session has data to process
|
|
29
|
+
*/
|
|
30
|
+
shouldProcess(session: ParsedSession): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Process session to aggregate metrics and write JSONL deltas
|
|
33
|
+
*
|
|
34
|
+
* Per tech spec ADR-1/G2: Validate metadata at START before any processing
|
|
35
|
+
*/
|
|
36
|
+
process(session: ParsedSession, _context: ProcessingContext): Promise<ProcessingResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Check if session should be processed (cooldown check per ADR-18)
|
|
39
|
+
*/
|
|
40
|
+
private shouldProcessSession;
|
|
41
|
+
/**
|
|
42
|
+
* Mark session as processed (ADR-18)
|
|
43
|
+
*/
|
|
44
|
+
private markSessionProcessed;
|
|
45
|
+
/**
|
|
46
|
+
* Transform messages to MetricDelta records
|
|
47
|
+
*
|
|
48
|
+
* Per ADR-16: One delta per assistant message with tokens
|
|
49
|
+
*/
|
|
50
|
+
private transformMessagesToDeltas;
|
|
51
|
+
/**
|
|
52
|
+
* Resolve token source with fallback (ADR-13)
|
|
53
|
+
*/
|
|
54
|
+
private resolveTokenSource;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve timestamp with fallback chain (ADR-13 G4)
|
|
57
|
+
*/
|
|
58
|
+
private resolveTimestamp;
|
|
59
|
+
/**
|
|
60
|
+
* Load parts for a message (ADR-11 - part-message validation)
|
|
61
|
+
*/
|
|
62
|
+
private loadPartsForMessage;
|
|
63
|
+
/**
|
|
64
|
+
* Extract tool metrics from parts (ADR-8, ADR-14)
|
|
65
|
+
*/
|
|
66
|
+
private extractToolMetrics;
|
|
67
|
+
/**
|
|
68
|
+
* Map tool status to success/failure/skip (ADR-14)
|
|
69
|
+
*/
|
|
70
|
+
private mapToolStatus;
|
|
71
|
+
/**
|
|
72
|
+
* Extract file operation from tool call (ADR-8, ADR-17)
|
|
73
|
+
* Only emits allowed file operation types.
|
|
74
|
+
*/
|
|
75
|
+
private extractFileOperation;
|
|
76
|
+
/**
|
|
77
|
+
* Extract user prompts from messages (ADR-10, ADR-20)
|
|
78
|
+
*/
|
|
79
|
+
private extractUserPrompts;
|
|
80
|
+
/**
|
|
81
|
+
* Extract user prompt text from message (ADR-10, ADR-20)
|
|
82
|
+
*/
|
|
83
|
+
private extractUserPromptText;
|
|
84
|
+
/**
|
|
85
|
+
* Get existing record IDs for deduplication (ADR-5)
|
|
86
|
+
* Uses tolerant JSONL reading to handle corrupted lines.
|
|
87
|
+
*/
|
|
88
|
+
private getExistingRecordIds;
|
|
89
|
+
/**
|
|
90
|
+
* Read existing deltas from JSONL file (ADR-5, ADR-21)
|
|
91
|
+
*/
|
|
92
|
+
private readExistingDeltas;
|
|
93
|
+
/**
|
|
94
|
+
* Get valid model string (ADR-6)
|
|
95
|
+
*/
|
|
96
|
+
private getValidModelString;
|
|
97
|
+
/**
|
|
98
|
+
* Update session.metrics for backward compatibility
|
|
99
|
+
*/
|
|
100
|
+
private updateSessionMetrics;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=opencode.metrics-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode.metrics-processor.d.ts","sourceRoot":"","sources":["../../../../../../src/agents/plugins/opencode/session/processors/opencode.metrics-processor.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AACvH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAkCpF;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,gBAAgB;IAC/D,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,QAAQ,KAAK;IAEtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;;IAMlC;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IAI9C;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqH7F;;OAEG;YACW,oBAAoB;IAkBlC;;OAEG;YACW,oBAAoB;IAalC;;;;OAIG;YACW,yBAAyB;IA2HvC;;OAEG;YACW,kBAAkB;IAiChC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAuBxB;;OAEG;YACW,mBAAmB;IA2CjC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiD1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAerB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA+F5B;;OAEG;YACW,kBAAkB;IAmBhC;;OAEG;YACW,qBAAqB;IAsCnC;;;OAGG;YACW,oBAAoB;IAUlC;;OAEG;YACW,kBAAkB;IAiBhC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAmC7B"}
|