@ironbee-ai/cli 0.6.2 → 0.7.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/CHANGELOG.md +6 -0
- package/README.md +167 -39
- package/dist/analysis/code-changes.js.map +1 -1
- package/dist/analysis/cross-session.js.map +1 -1
- package/dist/analysis/fix-effectiveness.js.map +1 -1
- package/dist/analysis/time-analysis.js.map +1 -1
- package/dist/analysis/verdict-details.js.map +1 -1
- package/dist/analysis/verification-quality.js.map +1 -1
- package/dist/analytics/classifier.d.ts +99 -0
- package/dist/analytics/classifier.d.ts.map +1 -0
- package/dist/analytics/classifier.js +380 -0
- package/dist/analytics/classifier.js.map +1 -0
- package/dist/analytics/emit.d.ts +67 -0
- package/dist/analytics/emit.d.ts.map +1 -0
- package/dist/analytics/emit.js +901 -0
- package/dist/analytics/emit.js.map +1 -0
- package/dist/analytics/errors.d.ts +33 -0
- package/dist/analytics/errors.d.ts.map +1 -0
- package/dist/analytics/errors.js +93 -0
- package/dist/analytics/errors.js.map +1 -0
- package/dist/analytics/hook-trigger.d.ts +39 -0
- package/dist/analytics/hook-trigger.d.ts.map +1 -0
- package/dist/analytics/hook-trigger.js +127 -0
- package/dist/analytics/hook-trigger.js.map +1 -0
- package/dist/analytics/log.d.ts +44 -0
- package/dist/analytics/log.d.ts.map +1 -0
- package/dist/analytics/log.js +158 -0
- package/dist/analytics/log.js.map +1 -0
- package/dist/analytics/merge.d.ts +40 -0
- package/dist/analytics/merge.d.ts.map +1 -0
- package/dist/analytics/merge.js +527 -0
- package/dist/analytics/merge.js.map +1 -0
- package/dist/analytics/pricing.d.ts +149 -0
- package/dist/analytics/pricing.d.ts.map +1 -0
- package/dist/analytics/pricing.js +179 -0
- package/dist/analytics/pricing.js.map +1 -0
- package/dist/analytics/projection.d.ts +356 -0
- package/dist/analytics/projection.d.ts.map +1 -0
- package/dist/analytics/projection.js +2281 -0
- package/dist/analytics/projection.js.map +1 -0
- package/dist/analytics/spawn.d.ts +28 -0
- package/dist/analytics/spawn.d.ts.map +1 -0
- package/dist/analytics/spawn.js +57 -0
- package/dist/analytics/spawn.js.map +1 -0
- package/dist/analytics/state.d.ts +58 -0
- package/dist/analytics/state.d.ts.map +1 -0
- package/dist/analytics/state.js +329 -0
- package/dist/analytics/state.js.map +1 -0
- package/dist/analytics/transcript.d.ts +150 -0
- package/dist/analytics/transcript.d.ts.map +1 -0
- package/dist/analytics/transcript.js +276 -0
- package/dist/analytics/transcript.js.map +1 -0
- package/dist/analytics/types.d.ts +875 -0
- package/dist/analytics/types.d.ts.map +1 -0
- package/dist/analytics/types.js +31 -0
- package/dist/analytics/types.js.map +1 -0
- package/dist/clients/base.d.ts +21 -2
- package/dist/clients/base.d.ts.map +1 -1
- package/dist/clients/claude/commands/ironbee-verify.md +15 -7
- package/dist/clients/claude/fragments/command-verify.node.md +33 -0
- package/dist/clients/claude/fragments/rule.node.md +29 -0
- package/dist/clients/claude/fragments/skill.node.md +77 -0
- package/dist/clients/claude/hooks/activity-end.d.ts +13 -0
- package/dist/clients/claude/hooks/activity-end.d.ts.map +1 -0
- package/dist/clients/claude/hooks/activity-end.js +42 -0
- package/dist/clients/claude/hooks/activity-end.js.map +1 -0
- package/dist/clients/claude/hooks/require-verdict.d.ts +3 -2
- package/dist/clients/claude/hooks/require-verdict.d.ts.map +1 -1
- package/dist/clients/claude/hooks/require-verdict.js +6 -5
- package/dist/clients/claude/hooks/require-verdict.js.map +1 -1
- package/dist/clients/claude/hooks/require-verification.d.ts +7 -4
- package/dist/clients/claude/hooks/require-verification.d.ts.map +1 -1
- package/dist/clients/claude/hooks/require-verification.js +44 -22
- package/dist/clients/claude/hooks/require-verification.js.map +1 -1
- package/dist/clients/claude/hooks/session-end.d.ts.map +1 -1
- package/dist/clients/claude/hooks/session-end.js +17 -2
- package/dist/clients/claude/hooks/session-end.js.map +1 -1
- package/dist/clients/claude/hooks/session-start.d.ts.map +1 -1
- package/dist/clients/claude/hooks/session-start.js +2 -1
- package/dist/clients/claude/hooks/session-start.js.map +1 -1
- package/dist/clients/claude/hooks/track-action-monitor.d.ts +27 -0
- package/dist/clients/claude/hooks/track-action-monitor.d.ts.map +1 -0
- package/dist/clients/claude/hooks/track-action-monitor.js +126 -0
- package/dist/clients/claude/hooks/track-action-monitor.js.map +1 -0
- package/dist/clients/claude/hooks/track-action.d.ts.map +1 -1
- package/dist/clients/claude/hooks/track-action.js +29 -20
- package/dist/clients/claude/hooks/track-action.js.map +1 -1
- package/dist/clients/claude/hooks/verify-gate.d.ts.map +1 -1
- package/dist/clients/claude/hooks/verify-gate.js +18 -1
- package/dist/clients/claude/hooks/verify-gate.js.map +1 -1
- package/dist/clients/claude/index.d.ts +4 -1
- package/dist/clients/claude/index.d.ts.map +1 -1
- package/dist/clients/claude/index.js +171 -94
- package/dist/clients/claude/index.js.map +1 -1
- package/dist/clients/claude/rules/ironbee-verification.md +41 -33
- package/dist/clients/claude/skills/ironbee-verification.md +93 -76
- package/dist/clients/cursor/commands/ironbee-verify/SKILL.md +18 -10
- package/dist/clients/cursor/fragments/command-verify.node.md +33 -0
- package/dist/clients/cursor/fragments/rule.node.md +29 -0
- package/dist/clients/cursor/fragments/skill.node.md +77 -0
- package/dist/clients/cursor/hooks/activity-end.d.ts +14 -0
- package/dist/clients/cursor/hooks/activity-end.d.ts.map +1 -0
- package/dist/clients/cursor/hooks/activity-end.js +45 -0
- package/dist/clients/cursor/hooks/activity-end.js.map +1 -0
- package/dist/clients/cursor/hooks/require-verdict.d.ts +1 -1
- package/dist/clients/cursor/hooks/require-verdict.js +4 -4
- package/dist/clients/cursor/hooks/require-verification.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/require-verification.js +42 -16
- package/dist/clients/cursor/hooks/require-verification.js.map +1 -1
- package/dist/clients/cursor/hooks/session-end.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/session-end.js +18 -2
- package/dist/clients/cursor/hooks/session-end.js.map +1 -1
- package/dist/clients/cursor/hooks/session-start.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/session-start.js +2 -1
- package/dist/clients/cursor/hooks/session-start.js.map +1 -1
- package/dist/clients/cursor/hooks/track-action-monitor.d.ts +27 -0
- package/dist/clients/cursor/hooks/track-action-monitor.d.ts.map +1 -0
- package/dist/clients/cursor/hooks/track-action-monitor.js +133 -0
- package/dist/clients/cursor/hooks/track-action-monitor.js.map +1 -0
- package/dist/clients/cursor/hooks/track-action.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/track-action.js +51 -23
- package/dist/clients/cursor/hooks/track-action.js.map +1 -1
- package/dist/clients/cursor/hooks/verify-gate.d.ts.map +1 -1
- package/dist/clients/cursor/hooks/verify-gate.js +14 -1
- package/dist/clients/cursor/hooks/verify-gate.js.map +1 -1
- package/dist/clients/cursor/index.d.ts +4 -1
- package/dist/clients/cursor/index.d.ts.map +1 -1
- package/dist/clients/cursor/index.js +117 -71
- package/dist/clients/cursor/index.js.map +1 -1
- package/dist/clients/cursor/rules/ironbee-verification.mdc +37 -29
- package/dist/clients/cursor/skills/ironbee-verification.md +93 -76
- package/dist/clients/registry.d.ts +14 -0
- package/dist/clients/registry.d.ts.map +1 -1
- package/dist/clients/registry.js +34 -0
- package/dist/clients/registry.js.map +1 -1
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +40 -0
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/backend-toggle.d.ts +45 -0
- package/dist/commands/backend-toggle.d.ts.map +1 -0
- package/dist/commands/backend-toggle.js +192 -0
- package/dist/commands/backend-toggle.js.map +1 -0
- package/dist/commands/disable-backend.d.ts +14 -0
- package/dist/commands/disable-backend.d.ts.map +1 -0
- package/dist/commands/disable-backend.js +34 -0
- package/dist/commands/disable-backend.js.map +1 -0
- package/dist/commands/disable-verification.d.ts +16 -0
- package/dist/commands/disable-verification.d.ts.map +1 -0
- package/dist/commands/disable-verification.js +36 -0
- package/dist/commands/disable-verification.js.map +1 -0
- package/dist/commands/enable-backend.d.ts +15 -0
- package/dist/commands/enable-backend.d.ts.map +1 -0
- package/dist/commands/enable-backend.js +35 -0
- package/dist/commands/enable-backend.js.map +1 -0
- package/dist/commands/enable-verification.d.ts +14 -0
- package/dist/commands/enable-verification.d.ts.map +1 -0
- package/dist/commands/enable-verification.js +34 -0
- package/dist/commands/enable-verification.js.map +1 -0
- package/dist/commands/hook.d.ts.map +1 -1
- package/dist/commands/hook.js +60 -0
- package/dist/commands/hook.js.map +1 -1
- package/dist/commands/import.d.ts +39 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +369 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +15 -20
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/process-analytics.d.ts +18 -0
- package/dist/commands/process-analytics.d.ts.map +1 -0
- package/dist/commands/process-analytics.js +57 -0
- package/dist/commands/process-analytics.js.map +1 -0
- package/dist/commands/queue.d.ts +2 -3
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +2 -3
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +29 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/verification-toggle.d.ts +47 -0
- package/dist/commands/verification-toggle.d.ts.map +1 -0
- package/dist/commands/verification-toggle.js +113 -0
- package/dist/commands/verification-toggle.js.map +1 -0
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +28 -0
- package/dist/commands/verify.js.map +1 -1
- package/dist/hooks/core/actions.d.ts +64 -67
- package/dist/hooks/core/actions.d.ts.map +1 -1
- package/dist/hooks/core/actions.js +39 -24
- package/dist/hooks/core/actions.js.map +1 -1
- package/dist/hooks/core/activity-end.d.ts +20 -0
- package/dist/hooks/core/activity-end.d.ts.map +1 -0
- package/dist/hooks/core/activity-end.js +23 -0
- package/dist/hooks/core/activity-end.js.map +1 -0
- package/dist/hooks/core/required-tools.d.ts +30 -0
- package/dist/hooks/core/required-tools.d.ts.map +1 -0
- package/dist/hooks/core/required-tools.js +70 -0
- package/dist/hooks/core/required-tools.js.map +1 -0
- package/dist/hooks/core/session-state.d.ts +12 -3
- package/dist/hooks/core/session-state.d.ts.map +1 -1
- package/dist/hooks/core/session-state.js +59 -0
- package/dist/hooks/core/session-state.js.map +1 -1
- package/dist/hooks/core/submit-verdict.d.ts.map +1 -1
- package/dist/hooks/core/submit-verdict.js +16 -12
- package/dist/hooks/core/submit-verdict.js.map +1 -1
- package/dist/hooks/core/verify-gate.d.ts +17 -3
- package/dist/hooks/core/verify-gate.d.ts.map +1 -1
- package/dist/hooks/core/verify-gate.js +312 -116
- package/dist/hooks/core/verify-gate.js.map +1 -1
- package/dist/import/claude/analytics-runner.d.ts +42 -0
- package/dist/import/claude/analytics-runner.d.ts.map +1 -0
- package/dist/import/claude/analytics-runner.js +213 -0
- package/dist/import/claude/analytics-runner.js.map +1 -0
- package/dist/import/claude/discovery.d.ts +22 -0
- package/dist/import/claude/discovery.d.ts.map +1 -0
- package/dist/import/claude/discovery.js +197 -0
- package/dist/import/claude/discovery.js.map +1 -0
- package/dist/import/claude/encoding.d.ts +50 -0
- package/dist/import/claude/encoding.d.ts.map +1 -0
- package/dist/import/claude/encoding.js +110 -0
- package/dist/import/claude/encoding.js.map +1 -0
- package/dist/import/claude/events/file-change.d.ts +28 -0
- package/dist/import/claude/events/file-change.d.ts.map +1 -0
- package/dist/import/claude/events/file-change.js +112 -0
- package/dist/import/claude/events/file-change.js.map +1 -0
- package/dist/import/claude/events/tool-call.d.ts +61 -0
- package/dist/import/claude/events/tool-call.d.ts.map +1 -0
- package/dist/import/claude/events/tool-call.js +119 -0
- package/dist/import/claude/events/tool-call.js.map +1 -0
- package/dist/import/claude/runner.d.ts +31 -0
- package/dist/import/claude/runner.d.ts.map +1 -0
- package/dist/import/claude/runner.js +280 -0
- package/dist/import/claude/runner.js.map +1 -0
- package/dist/import/claude/summary.d.ts +23 -0
- package/dist/import/claude/summary.d.ts.map +1 -0
- package/dist/import/claude/summary.js +186 -0
- package/dist/import/claude/summary.js.map +1 -0
- package/dist/import/claude/transcript-walk.d.ts +52 -0
- package/dist/import/claude/transcript-walk.d.ts.map +1 -0
- package/dist/import/claude/transcript-walk.js +187 -0
- package/dist/import/claude/transcript-walk.js.map +1 -0
- package/dist/import/concurrent-pool.d.ts +45 -0
- package/dist/import/concurrent-pool.d.ts.map +1 -0
- package/dist/import/concurrent-pool.js +95 -0
- package/dist/import/concurrent-pool.js.map +1 -0
- package/dist/import/emitter.d.ts +29 -0
- package/dist/import/emitter.d.ts.map +1 -0
- package/dist/import/emitter.js +66 -0
- package/dist/import/emitter.js.map +1 -0
- package/dist/import/events/activity.d.ts +23 -0
- package/dist/import/events/activity.d.ts.map +1 -0
- package/dist/import/events/activity.js +45 -0
- package/dist/import/events/activity.js.map +1 -0
- package/dist/import/events/session.d.ts +24 -0
- package/dist/import/events/session.d.ts.map +1 -0
- package/dist/import/events/session.js +47 -0
- package/dist/import/events/session.js.map +1 -0
- package/dist/import/filter.d.ts +47 -0
- package/dist/import/filter.d.ts.map +1 -0
- package/dist/import/filter.js +90 -0
- package/dist/import/filter.js.map +1 -0
- package/dist/import/ids.d.ts +56 -0
- package/dist/import/ids.d.ts.map +1 -0
- package/dist/import/ids.js +87 -0
- package/dist/import/ids.js.map +1 -0
- package/dist/import/index.d.ts +29 -0
- package/dist/import/index.d.ts.map +1 -0
- package/dist/import/index.js +52 -0
- package/dist/import/index.js.map +1 -0
- package/dist/import/marker.d.ts +20 -0
- package/dist/import/marker.d.ts.map +1 -0
- package/dist/import/marker.js +71 -0
- package/dist/import/marker.js.map +1 -0
- package/dist/import/pipeline.d.ts +41 -0
- package/dist/import/pipeline.d.ts.map +1 -0
- package/dist/import/pipeline.js +47 -0
- package/dist/import/pipeline.js.map +1 -0
- package/dist/import/progress.d.ts +20 -0
- package/dist/import/progress.d.ts.map +1 -0
- package/dist/import/progress.js +69 -0
- package/dist/import/progress.js.map +1 -0
- package/dist/import/skip.d.ts +13 -0
- package/dist/import/skip.d.ts.map +1 -0
- package/dist/import/skip.js +24 -0
- package/dist/import/skip.js.map +1 -0
- package/dist/import/types.d.ts +125 -0
- package/dist/import/types.d.ts.map +1 -0
- package/dist/import/types.js +28 -0
- package/dist/import/types.js.map +1 -0
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/collector.d.ts +29 -3
- package/dist/lib/collector.d.ts.map +1 -1
- package/dist/lib/collector.js +118 -8
- package/dist/lib/collector.js.map +1 -1
- package/dist/lib/config.d.ts +240 -83
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +482 -89
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/event.d.ts +72 -0
- package/dist/lib/event.d.ts.map +1 -0
- package/dist/lib/event.js +42 -0
- package/dist/lib/event.js.map +1 -0
- package/dist/lib/gitignore.d.ts +21 -0
- package/dist/lib/gitignore.d.ts.map +1 -0
- package/dist/lib/gitignore.js +54 -0
- package/dist/lib/gitignore.js.map +1 -0
- package/dist/lib/runtime-section.d.ts +118 -0
- package/dist/lib/runtime-section.d.ts.map +1 -0
- package/dist/lib/runtime-section.js +256 -0
- package/dist/lib/runtime-section.js.map +1 -0
- package/dist/lib/telemetry.d.ts +1 -1
- package/dist/lib/telemetry.d.ts.map +1 -1
- package/dist/lib/telemetry.js +4 -1
- package/dist/lib/telemetry.js.map +1 -1
- package/dist/queue/dead-letter.d.ts +5 -1
- package/dist/queue/dead-letter.d.ts.map +1 -1
- package/dist/queue/dead-letter.js +5 -1
- package/dist/queue/dead-letter.js.map +1 -1
- package/dist/queue/drain.d.ts +3 -2
- package/dist/queue/drain.d.ts.map +1 -1
- package/dist/queue/drain.js +3 -2
- package/dist/queue/drain.js.map +1 -1
- package/dist/queue/flush.d.ts +28 -12
- package/dist/queue/flush.d.ts.map +1 -1
- package/dist/queue/flush.js +43 -18
- package/dist/queue/flush.js.map +1 -1
- package/dist/queue/handlers/send-event.d.ts.map +1 -1
- package/dist/queue/handlers/send-event.js.map +1 -1
- package/dist/queue/index.d.ts +1 -2
- package/dist/queue/index.d.ts.map +1 -1
- package/dist/queue/index.js +2 -2
- package/dist/queue/index.js.map +1 -1
- package/dist/queue/paths.d.ts +4 -2
- package/dist/queue/paths.d.ts.map +1 -1
- package/dist/queue/paths.js +4 -2
- package/dist/queue/paths.js.map +1 -1
- package/dist/queue/process-file.d.ts +5 -1
- package/dist/queue/process-file.d.ts.map +1 -1
- package/dist/queue/process-file.js +5 -1
- package/dist/queue/process-file.js.map +1 -1
- package/dist/queue/snapshot.d.ts +4 -1
- package/dist/queue/snapshot.d.ts.map +1 -1
- package/dist/queue/snapshot.js +4 -1
- package/dist/queue/snapshot.js.map +1 -1
- package/dist/queue/spawn.d.ts +1 -3
- package/dist/queue/spawn.d.ts.map +1 -1
- package/dist/queue/spawn.js +1 -3
- package/dist/queue/spawn.js.map +1 -1
- package/dist/queue/submit.d.ts +6 -1
- package/dist/queue/submit.d.ts.map +1 -1
- package/dist/queue/submit.js +6 -1
- package/dist/queue/submit.js.map +1 -1
- package/dist/queue/types.d.ts +5 -1
- package/dist/queue/types.d.ts.map +1 -1
- package/dist/queue/types.js +5 -1
- package/dist/queue/types.js.map +1 -1
- package/dist/queue/worker-log.d.ts +3 -1
- package/dist/queue/worker-log.d.ts.map +1 -1
- package/dist/queue/worker-log.js +3 -1
- package/dist/queue/worker-log.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Import Module Project-Path Encoding
|
|
4
|
+
*
|
|
5
|
+
* Forward + reverse mapping between absolute filesystem paths and Claude
|
|
6
|
+
* Code's transcript-folder convention.
|
|
7
|
+
*
|
|
8
|
+
* Forward (path → folder name): reuses `src/analytics/transcript.ts:sanitizeProjectPath`
|
|
9
|
+
* which replaces every non-alphanumeric character with `-`. This matches what
|
|
10
|
+
* Claude Code does in its own transcript writer.
|
|
11
|
+
*
|
|
12
|
+
* Reverse (folder name → path): the encoding is lossy — `/`, `.`, `_`, etc.
|
|
13
|
+
* all collapse to `-`, so we cannot recover the original path from the folder
|
|
14
|
+
* name alone. We try a small set of plausible interpretations against
|
|
15
|
+
* `fs.existsSync` and pick the first one that resolves to a real directory.
|
|
16
|
+
* On miss, we fall back to using the encoded folder name as a synthetic
|
|
17
|
+
* identifier (the only consumer past that point is the skip rule's
|
|
18
|
+
* `existsSync` check, which trivially returns false for synthetic paths).
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.encodeProjectFolder = encodeProjectFolder;
|
|
24
|
+
exports.decodeProjectFolder = decodeProjectFolder;
|
|
25
|
+
exports.resolveProjectFromFolder = resolveProjectFromFolder;
|
|
26
|
+
const fs_1 = require("fs");
|
|
27
|
+
const actions_1 = require("../../hooks/core/actions");
|
|
28
|
+
const transcript_1 = require("../../analytics/transcript");
|
|
29
|
+
/** Forward: absolute path → encoded folder name. */
|
|
30
|
+
function encodeProjectFolder(absPath) {
|
|
31
|
+
return (0, transcript_1.sanitizeProjectPath)(absPath);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Reverse: encoded folder name → best-effort absolute path.
|
|
35
|
+
*
|
|
36
|
+
* Walks the encoded segments, trying each `-` as `/`, `.`, `_`, or literal `-`
|
|
37
|
+
* (in that priority order — `/` first because directory separators are by
|
|
38
|
+
* far the dominant case). Stops on the first interpretation whose path
|
|
39
|
+
* exists on disk. Returns `null` when nothing matches.
|
|
40
|
+
*
|
|
41
|
+
* The walk is depth-first and bounded: with N dashes the worst case is 4^N
|
|
42
|
+
* combinations, but in practice the first-existing-match short-circuit caps
|
|
43
|
+
* runtime to a handful of `existsSync` calls. We cap the dash count at 30 to
|
|
44
|
+
* defend against pathological input — encoded folders longer than that are
|
|
45
|
+
* highly unusual and we just decline to decode them.
|
|
46
|
+
*/
|
|
47
|
+
function decodeProjectFolder(folderName) {
|
|
48
|
+
if (folderName.length === 0) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
// Encoded folders always start with `-` (leading slash). Strip it before
|
|
52
|
+
// splitting so we don't materialize an empty leading segment.
|
|
53
|
+
const trimmed = folderName.startsWith("-") ? folderName.slice(1) : folderName;
|
|
54
|
+
// Split on consecutive dashes — runs of dashes in the encoded form
|
|
55
|
+
// typically represent path separators around alphanumeric segments.
|
|
56
|
+
// Single dashes are ambiguous; we walk them.
|
|
57
|
+
const parts = trimmed.split("-");
|
|
58
|
+
if (parts.length > 31) {
|
|
59
|
+
return null; // too many dashes — refuse to brute-force
|
|
60
|
+
}
|
|
61
|
+
const candidates = ["/", ".", "_", "-"];
|
|
62
|
+
return walk(parts, 0, "/", candidates);
|
|
63
|
+
}
|
|
64
|
+
function walk(parts, idx, accum, candidates) {
|
|
65
|
+
if (idx === parts.length - 1) {
|
|
66
|
+
const final = accum + parts[idx];
|
|
67
|
+
return (0, fs_1.existsSync)(final) ? final : null;
|
|
68
|
+
}
|
|
69
|
+
for (const sep of candidates) {
|
|
70
|
+
const next = accum + parts[idx] + sep;
|
|
71
|
+
// Eager prune: if the partial path's parent doesn't exist for `/`,
|
|
72
|
+
// there's no point recursing — same heuristic for the others, but
|
|
73
|
+
// we only enforce on `/` because non-`/` interpretations are inside
|
|
74
|
+
// the same parent directory and a partial-prefix existsSync isn't
|
|
75
|
+
// meaningful for them.
|
|
76
|
+
if (sep === "/" && !(0, fs_1.existsSync)(accum)) {
|
|
77
|
+
// accum is e.g. "/Users/" — even the parent is missing, give up
|
|
78
|
+
// on further `/` interpretations. But still try the same-dir
|
|
79
|
+
// alternatives below (`.`, `_`, `-`).
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const result = walk(parts, idx + 1, next, candidates);
|
|
83
|
+
if (result !== null) {
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Best-effort decode plus a `(projectDir, projectName)` resolver that always
|
|
91
|
+
* returns something. When the reverse-decode fails, returns the encoded
|
|
92
|
+
* folder name in both fields so downstream consumers (skip rule, marker
|
|
93
|
+
* write) can still proceed — they handle non-existent project dirs
|
|
94
|
+
* gracefully.
|
|
95
|
+
*/
|
|
96
|
+
function resolveProjectFromFolder(folderName) {
|
|
97
|
+
const decoded = decodeProjectFolder(folderName);
|
|
98
|
+
if (decoded !== null) {
|
|
99
|
+
// Use resolveProjectName so the wire `project_name` matches live
|
|
100
|
+
// mode for the same path — walks up looking for `.git`, falls back
|
|
101
|
+
// to basename. Important when the user ran Claude from a subdir of
|
|
102
|
+
// a git repo: live emits the repo basename, import must too.
|
|
103
|
+
return { projectDir: decoded, projectName: (0, actions_1.resolveProjectName)(decoded), existsOnDisk: true };
|
|
104
|
+
}
|
|
105
|
+
// No real path on disk — use the encoded folder name as a synthetic
|
|
106
|
+
// identifier in both fields. Skip rule and marker write handle the
|
|
107
|
+
// non-existent projectDir case downstream.
|
|
108
|
+
return { projectDir: folderName, projectName: folderName, existsOnDisk: false };
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../../src/import/claude/encoding.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAOH,kDAEC;AAgBD,kDAgBC;AAmCD,4DAaC;AAvFD,2BAAgC;AAChC,sDAA8D;AAC9D,2DAAiE;AAEjE,oDAAoD;AACpD,SAAgB,mBAAmB,CAAC,OAAe;IAC/C,OAAO,IAAA,gCAAmB,EAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,mBAAmB,CAAC,UAAkB;IAClD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC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DAA6D;YAC7D,sCAAsC;YACtC,SAAS;QACb,CAAC;QACD,MAAM,MAAM,GAAkB,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QACrE,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClB,OAAO,MAAM,CAAC;QAClB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,wBAAwB,CAAC,UAAkB;IACvD,MAAM,OAAO,GAAkB,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC/D,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACnB,iEAAiE;QACjE,mEAAmE;QACnE,mEAAmE;QACnE,6DAA6D;QAC7D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,IAAA,4BAAkB,EAAC,OAAO,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACjG,CAAC;IACD,oEAAoE;IACpE,mEAAmE;IACnE,2CAA2C;IAC3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Import file_change derivation.
|
|
3
|
+
*
|
|
4
|
+
* One `file_change` event per `Write`/`Edit` tool_use. Filters via the
|
|
5
|
+
* current project config's verifyPatterns / ignoredVerifyPatterns (since
|
|
6
|
+
* historical config values are unrecoverable, we use the current snapshot).
|
|
7
|
+
*
|
|
8
|
+
* Operation heuristic: live mode uses pre-tool-use `existsSync`, which we
|
|
9
|
+
* cannot replay. We inspect the matched `tool_result.content` for a
|
|
10
|
+
* "created"/"updated" marker and default to "update" on miss.
|
|
11
|
+
*/
|
|
12
|
+
import { FileChangeAction } from "../../../hooks/core/actions";
|
|
13
|
+
import { IronBeeConfig } from "../../../lib/config";
|
|
14
|
+
import { RawToolUse, RawToolResult } from "./tool-call";
|
|
15
|
+
export interface BuildFileChangeOpts {
|
|
16
|
+
sessionId: string;
|
|
17
|
+
projectName: string;
|
|
18
|
+
/** Parent turn's activity_id. */
|
|
19
|
+
activityId: string;
|
|
20
|
+
/** ISO timestamp from the assistant line. */
|
|
21
|
+
timestamp: string;
|
|
22
|
+
toolUse: RawToolUse;
|
|
23
|
+
toolResult: RawToolResult | null;
|
|
24
|
+
config: IronBeeConfig;
|
|
25
|
+
}
|
|
26
|
+
/** Returns null when the tool_use is not a Write/Edit, or the file is filtered. */
|
|
27
|
+
export declare function buildFileChange(opts: BuildFileChangeOpts): FileChangeAction | null;
|
|
28
|
+
//# sourceMappingURL=file-change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-change.d.ts","sourceRoot":"","sources":["../../../../src/import/claude/events/file-change.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAuB,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAwB,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,WAAW,mBAAmB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,aAAa,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,aAAa,CAAC;CACzB;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,IAAI,CAuDlF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Import file_change derivation.
|
|
4
|
+
*
|
|
5
|
+
* One `file_change` event per `Write`/`Edit` tool_use. Filters via the
|
|
6
|
+
* current project config's verifyPatterns / ignoredVerifyPatterns (since
|
|
7
|
+
* historical config values are unrecoverable, we use the current snapshot).
|
|
8
|
+
*
|
|
9
|
+
* Operation heuristic: live mode uses pre-tool-use `existsSync`, which we
|
|
10
|
+
* cannot replay. We inspect the matched `tool_result.content` for a
|
|
11
|
+
* "created"/"updated" marker and default to "update" on miss.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.buildFileChange = buildFileChange;
|
|
15
|
+
const file_diff_1 = require("../../../hooks/core/file-diff");
|
|
16
|
+
const config_1 = require("../../../lib/config");
|
|
17
|
+
const ids_1 = require("../../ids");
|
|
18
|
+
/** Returns null when the tool_use is not a Write/Edit, or the file is filtered. */
|
|
19
|
+
function buildFileChange(opts) {
|
|
20
|
+
const { sessionId, projectName, activityId, timestamp, toolUse, toolResult, config } = opts;
|
|
21
|
+
const toolName = toolUse.name;
|
|
22
|
+
if (toolName !== "Write" && toolName !== "Edit") {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const filePath = readString(toolUse.input, "file_path");
|
|
26
|
+
if (filePath === undefined) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (!(0, config_1.requiresVerification)(filePath, config)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
let operation;
|
|
33
|
+
let linesAdded;
|
|
34
|
+
let linesRemoved;
|
|
35
|
+
if (toolName === "Edit") {
|
|
36
|
+
const oldStr = readString(toolUse.input, "old_string") ?? "";
|
|
37
|
+
const newStr = readString(toolUse.input, "new_string") ?? "";
|
|
38
|
+
const counts = (0, file_diff_1.diffLineCounts)(oldStr, newStr);
|
|
39
|
+
operation = "update";
|
|
40
|
+
linesAdded = counts.added;
|
|
41
|
+
linesRemoved = counts.removed;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Write
|
|
45
|
+
const content = readString(toolUse.input, "content") ?? "";
|
|
46
|
+
operation = inferOperationFromResult(toolResult);
|
|
47
|
+
linesAdded = (0, file_diff_1.countLines)(content);
|
|
48
|
+
linesRemoved = null; // we don't pre-read prior content; matches live behavior
|
|
49
|
+
}
|
|
50
|
+
const tsMs = Date.parse(timestamp);
|
|
51
|
+
// Import has no fix cycles, so `fix_id` is OMITTED from the wire payload
|
|
52
|
+
// (matches live mode's behavior when no fix is active — `getActiveFixId`
|
|
53
|
+
// returns undefined and JSON.stringify drops the key). Earlier we set
|
|
54
|
+
// `fix_id: ""` literally, which made it past TS `FixAwareEvent.fix_id:
|
|
55
|
+
// string` typing but was rejected by the collector's schema validator
|
|
56
|
+
// (Java side likely has `@NotBlank` on the field). The cast lets us
|
|
57
|
+
// satisfy the TS type without emitting the empty value on the wire.
|
|
58
|
+
const event = {
|
|
59
|
+
id: (0, ids_1.deriveFileChangeEventId)(sessionId, toolUse.id),
|
|
60
|
+
type: "file_change",
|
|
61
|
+
timestamp: Number.isFinite(tsMs) ? tsMs : Date.now(),
|
|
62
|
+
session_id: sessionId,
|
|
63
|
+
project_name: projectName,
|
|
64
|
+
activity_id: activityId,
|
|
65
|
+
tool_name: toolName,
|
|
66
|
+
file_path: filePath,
|
|
67
|
+
operation,
|
|
68
|
+
lines_added: linesAdded,
|
|
69
|
+
lines_removed: linesRemoved,
|
|
70
|
+
};
|
|
71
|
+
return event;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Operation heuristic for `Write`. Inspects the matched
|
|
75
|
+
* `tool_result.content` text for "created"/"File created"/"updated" markers.
|
|
76
|
+
* Defaults to `"update"` on miss (the safer fallback — we'd rather mislabel
|
|
77
|
+
* a create as update than the reverse, since "update" is the dominant case
|
|
78
|
+
* in real sessions). Always returns a definite operation.
|
|
79
|
+
*/
|
|
80
|
+
function inferOperationFromResult(result) {
|
|
81
|
+
if (result === null || result.is_error) {
|
|
82
|
+
return "update";
|
|
83
|
+
}
|
|
84
|
+
const text = stringifyContent(result.content).toLowerCase();
|
|
85
|
+
if (text.includes("file created") || text.includes("created successfully")) {
|
|
86
|
+
return "create";
|
|
87
|
+
}
|
|
88
|
+
return "update";
|
|
89
|
+
}
|
|
90
|
+
function stringifyContent(content) {
|
|
91
|
+
if (typeof content === "string") {
|
|
92
|
+
return content;
|
|
93
|
+
}
|
|
94
|
+
if (Array.isArray(content)) {
|
|
95
|
+
const parts = [];
|
|
96
|
+
for (const block of content) {
|
|
97
|
+
if (block !== null && typeof block === "object") {
|
|
98
|
+
const text = block.text;
|
|
99
|
+
if (typeof text === "string") {
|
|
100
|
+
parts.push(text);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return parts.join("\n");
|
|
105
|
+
}
|
|
106
|
+
return "";
|
|
107
|
+
}
|
|
108
|
+
function readString(input, key) {
|
|
109
|
+
const value = input[key];
|
|
110
|
+
return typeof value === "string" ? value : undefined;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=file-change.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-change.js","sourceRoot":"","sources":["../../../../src/import/claude/events/file-change.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAqBH,0CAuDC;AAzED,6DAA2F;AAC3F,gDAA0E;AAC1E,mCAAoD;AAepD,mFAAmF;AACnF,SAAgB,eAAe,CAAC,IAAyB;IACrD,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5F,MAAM,QAAQ,GAAW,OAAO,CAAC,IAAI,CAAC;IACtC,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,QAAQ,GAAuB,UAAU,C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AAI,CAAC;gBACzD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC3B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED,SAAS,UAAU,CAAC,KAA8B,EAAE,GAAW;IAC3D,MAAM,KAAK,GAAY,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Import tool_call derivation.
|
|
3
|
+
*
|
|
4
|
+
* One `tool_call` event per `tool_use` block in any assistant message.
|
|
5
|
+
*
|
|
6
|
+
* For `bdt_` / `ndt_` (devtools-MCP) tools: when `_metadata.toolCallId` is
|
|
7
|
+
* present in the transcript, use it as the event `id`
|
|
8
|
+
* verbatim. Live MCP-shipped events use the same id, so collector dedup on
|
|
9
|
+
* `(session_id, id)` collapses live↔import duplicates. For older transcripts
|
|
10
|
+
* without `toolCallId` (or for any non-devtools tool), fall back to the
|
|
11
|
+
* deterministic formula from `tool_use.id`.
|
|
12
|
+
*
|
|
13
|
+
* `tool_input` is whitelisted via `extractClaudeToolInput` — same projection
|
|
14
|
+
* the live track-action hook applies. `tool_response` is not shipped on the
|
|
15
|
+
* wire, only its byte size.
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
import { ToolCallAction } from "../../../hooks/core/actions";
|
|
20
|
+
/** Lightly-typed tool_use shape we walk out of the transcript. */
|
|
21
|
+
export interface RawToolUse {
|
|
22
|
+
/** `tool_use.id` — host-supplied per-call identifier. */
|
|
23
|
+
id: string;
|
|
24
|
+
/** Raw tool name with prefix (e.g. `mcp__browser-devtools__bdt_navigation_go-to`). */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Raw input — may contain `_metadata` for devtools (bdt_/ndt_) tools. */
|
|
27
|
+
input: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/** Lightly-typed tool_result shape. `null` means no matching result yet. */
|
|
30
|
+
export interface RawToolResult {
|
|
31
|
+
/** Joined to `tool_use.id`. */
|
|
32
|
+
tool_use_id: string;
|
|
33
|
+
/** `is_error: true` is propagated to event.error. */
|
|
34
|
+
is_error: boolean;
|
|
35
|
+
/** Content block — string or array. Used for size + error message extraction. */
|
|
36
|
+
content: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface BuildToolCallOpts {
|
|
39
|
+
sessionId: string;
|
|
40
|
+
projectName: string;
|
|
41
|
+
/** Parent turn's activity_id (from `deriveActivityId`). */
|
|
42
|
+
activityId: string;
|
|
43
|
+
/** ISO timestamp from the assistant line carrying the tool_use. */
|
|
44
|
+
timestamp: string;
|
|
45
|
+
toolUse: RawToolUse;
|
|
46
|
+
/** Matched tool_result for this tool_use, or null when unmatched. */
|
|
47
|
+
toolResult: RawToolResult | null;
|
|
48
|
+
/**
|
|
49
|
+
* Estimated duration in ms. Live mode reads `duration_ms` from the
|
|
50
|
+
* PostToolUse hook stdin (exact wall-clock per call). Transcripts don't
|
|
51
|
+
* carry per-tool latency, so the import runner approximates by computing
|
|
52
|
+
* the bracket between the assistant message timestamp and the next user
|
|
53
|
+
* message timestamp — accurate for messages with a single tool_use,
|
|
54
|
+
* approximate (an upper bound) for parallel multi-tool messages. The
|
|
55
|
+
* runner passes `null` in those ambiguous cases; we forward `null`
|
|
56
|
+
* verbatim and downstream treats it as "unknown" (NOT zero).
|
|
57
|
+
*/
|
|
58
|
+
durationMs?: number | null;
|
|
59
|
+
}
|
|
60
|
+
export declare function buildToolCall(opts: BuildToolCallOpts): ToolCallAction;
|
|
61
|
+
//# sourceMappingURL=tool-call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../../../src/import/claude/events/tool-call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAM7D,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACvB,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAC;IACX,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC1B,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,QAAQ,EAAE,OAAO,CAAC;IAClB,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,qEAAqE;IACrE,UAAU,EAAE,aAAa,GAAG,IAAI,CAAC;IACjC;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,CAgDrE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* IronBee CLI — Import tool_call derivation.
|
|
4
|
+
*
|
|
5
|
+
* One `tool_call` event per `tool_use` block in any assistant message.
|
|
6
|
+
*
|
|
7
|
+
* For `bdt_` / `ndt_` (devtools-MCP) tools: when `_metadata.toolCallId` is
|
|
8
|
+
* present in the transcript, use it as the event `id`
|
|
9
|
+
* verbatim. Live MCP-shipped events use the same id, so collector dedup on
|
|
10
|
+
* `(session_id, id)` collapses live↔import duplicates. For older transcripts
|
|
11
|
+
* without `toolCallId` (or for any non-devtools tool), fall back to the
|
|
12
|
+
* deterministic formula from `tool_use.id`.
|
|
13
|
+
*
|
|
14
|
+
* `tool_input` is whitelisted via `extractClaudeToolInput` — same projection
|
|
15
|
+
* the live track-action hook applies. `tool_response` is not shipped on the
|
|
16
|
+
* wire, only its byte size.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.buildToolCall = buildToolCall;
|
|
22
|
+
const util_1 = require("../../../clients/claude/util");
|
|
23
|
+
const ids_1 = require("../../ids");
|
|
24
|
+
const DEVTOOLS_MCP_SERVERS = new Set(["browser-devtools", "node-devtools"]);
|
|
25
|
+
function buildToolCall(opts) {
|
|
26
|
+
const { sessionId, projectName, activityId, timestamp, toolUse, toolResult } = opts;
|
|
27
|
+
const classified = (0, util_1.classifyTool)(toolUse.name, toolUse.input);
|
|
28
|
+
// Event id: prefer _metadata.toolCallId for devtools (bdt_/ndt_) tools
|
|
29
|
+
// when present in the transcript; otherwise fall back to
|
|
30
|
+
// deterministic-from-tool_use_id.
|
|
31
|
+
const eventId = resolveEventId(sessionId, classified, toolUse);
|
|
32
|
+
// tool_input projection: whitelist via extractClaudeToolInput. For
|
|
33
|
+
// browser-devtools/node-devtools tools, util.ts intentionally bypasses
|
|
34
|
+
// extraction and returns the raw input — that's fine for actions.jsonl
|
|
35
|
+
// but on the wire we still want it pruned. Since we are NOT going through
|
|
36
|
+
// the live track-action queue path, we just ship whatever extractClaudeToolInput
|
|
37
|
+
// returns (matches live wire shape for non-devtools; for devtools, includes
|
|
38
|
+
// _metadata which collector consumers already tolerate).
|
|
39
|
+
const projectedInput = (0, util_1.extractClaudeToolInput)(toolUse.name, toolUse.input);
|
|
40
|
+
const inputSize = byteLengthOf(toolUse.input);
|
|
41
|
+
const responseSize = toolResult !== null ? byteLengthOf(toolResult.content) : 0;
|
|
42
|
+
const errorMsg = toolResult !== null && toolResult.is_error
|
|
43
|
+
? extractErrorMessage(toolResult.content)
|
|
44
|
+
: undefined;
|
|
45
|
+
const tsMs = Date.parse(timestamp);
|
|
46
|
+
const event = {
|
|
47
|
+
id: eventId,
|
|
48
|
+
type: "tool_call",
|
|
49
|
+
timestamp: Number.isFinite(tsMs) ? tsMs : Date.now(),
|
|
50
|
+
session_id: sessionId,
|
|
51
|
+
project_name: projectName,
|
|
52
|
+
activity_id: activityId,
|
|
53
|
+
tool_name: classified.tool_name,
|
|
54
|
+
tool_use_id: toolUse.id,
|
|
55
|
+
tool_input: projectedInput,
|
|
56
|
+
tool_input_size: inputSize,
|
|
57
|
+
tool_response_size: responseSize,
|
|
58
|
+
duration: opts.durationMs ?? null,
|
|
59
|
+
};
|
|
60
|
+
if (classified.tool_type !== null) {
|
|
61
|
+
event.tool_type = classified.tool_type;
|
|
62
|
+
}
|
|
63
|
+
if (classified.mcp_server !== null) {
|
|
64
|
+
event.mcp_server = classified.mcp_server;
|
|
65
|
+
}
|
|
66
|
+
if (errorMsg !== undefined) {
|
|
67
|
+
event.error = errorMsg;
|
|
68
|
+
}
|
|
69
|
+
return event;
|
|
70
|
+
}
|
|
71
|
+
function resolveEventId(sessionId, classified, toolUse) {
|
|
72
|
+
if (classified.tool_type === "mcp"
|
|
73
|
+
&& classified.mcp_server !== null
|
|
74
|
+
&& DEVTOOLS_MCP_SERVERS.has(classified.mcp_server)) {
|
|
75
|
+
const meta = toolUse.input._metadata;
|
|
76
|
+
if (meta !== null && typeof meta === "object") {
|
|
77
|
+
const toolCallId = meta.toolCallId;
|
|
78
|
+
if (typeof toolCallId === "string" && toolCallId.length > 0) {
|
|
79
|
+
return toolCallId;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return (0, ids_1.deriveToolCallEventIdFromToolUseId)(sessionId, toolUse.id);
|
|
84
|
+
}
|
|
85
|
+
function byteLengthOf(value) {
|
|
86
|
+
if (value === undefined || value === null) {
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
return Buffer.byteLength(JSON.stringify(value), "utf-8");
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function extractErrorMessage(content) {
|
|
97
|
+
if (typeof content === "string") {
|
|
98
|
+
return content;
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(content)) {
|
|
101
|
+
const parts = [];
|
|
102
|
+
for (const block of content) {
|
|
103
|
+
if (block !== null && typeof block === "object") {
|
|
104
|
+
const text = block.text;
|
|
105
|
+
if (typeof text === "string") {
|
|
106
|
+
parts.push(text);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return parts.join("\n");
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
return JSON.stringify(content);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return String(content);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=tool-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call.js","sourceRoot":"","sources":["../../../../src/import/claude/events/tool-call.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAmDH,sCAgDC;AAhGD,uDAAoG;AACpG,mCAA+D;AAE/D,MAAM,oBAAoB,GAAgB,IAAI,GAAG,CAAS,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC;AA6CjG,SAAgB,aAAa,CAAC,IAAuB;IACjD,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACpF,MAAM,UAAU,GAAmB,IAAA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AAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,CAAC,CAAC;IACb,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAgB;IACzC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,OAAoB,EAAE,CAAC;YACvC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9C,MAAM,IAAI,GAAa,KAA4B,CAAC,IAAI,CAAC;gBACzD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC3B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IronBee CLI — Claude Per-Session Import Runner
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the full import of one Claude transcript:
|
|
5
|
+
* 1. Skip check (`<projectDir>/.ironbee/sessions/<id>/`).
|
|
6
|
+
* 2. Run analytics-runner — produces session_analytics + turn + step +
|
|
7
|
+
* api_request events.
|
|
8
|
+
* 3. Walk the Claude transcript separately for non-analytics events:
|
|
9
|
+
* session_start, session_end, activity_start/end (per turn,
|
|
10
|
+
* host_inject suppressed), tool_call (per tool_use), file_change
|
|
11
|
+
* (Write/Edit).
|
|
12
|
+
* 4. POST all events via the import emitter (transient retry).
|
|
13
|
+
* 5. Write the marker.
|
|
14
|
+
*
|
|
15
|
+
* Claude-specific because the transcript walk depends on Claude's JSONL
|
|
16
|
+
* shape. When Cursor support lands, a parallel `cursor/runner.ts` will
|
|
17
|
+
* implement the same `IClientRunner` contract — never mixed in this file.
|
|
18
|
+
*
|
|
19
|
+
* Per-session atomicity: on any unrecoverable failure mid-emit,
|
|
20
|
+
* the marker is NOT written and the session re-attempts on the next
|
|
21
|
+
* `ironbee import` run.
|
|
22
|
+
*/
|
|
23
|
+
import { ImportResult, ImportTarget } from "../types";
|
|
24
|
+
export interface ClaudeRunnerOpts {
|
|
25
|
+
target: ImportTarget;
|
|
26
|
+
force: boolean;
|
|
27
|
+
/** Events per collector POST; null = use target/default. */
|
|
28
|
+
batchSize?: number | null;
|
|
29
|
+
}
|
|
30
|
+
export declare function importClaudeSession(opts: ClaudeRunnerOpts): Promise<ImportResult>;
|
|
31
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/import/claude/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,OAAO,EAIH,YAAY,EACZ,YAAY,EACf,MAAM,UAAU,CAAC;AAqBlB,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAoNvF"}
|