codiedev 0.10.0-beta.4 → 0.10.0-beta.5
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 +7 -1
- package/assets/tui-brand-plugin.tsx +14 -2
- package/dist/backup/cache.js +1 -5
- package/dist/backup/match.js +0 -6
- package/dist/backup/run.js +3 -35
- package/dist/captureExclusions.js +0 -12
- package/dist/captureLog.js +0 -28
- package/dist/captureReadiness.js +0 -58
- package/dist/captureSignals.js +66 -3
- package/dist/cli.js +41 -18
- package/dist/codexHookTrust.js +61 -5
- package/dist/codexLimitScan.js +2 -109
- package/dist/codie.js +27 -40
- package/dist/codieBrandInstall.js +0 -18
- package/dist/codieLauncher.js +2 -70
- package/dist/codieRuntime.js +19 -23
- package/dist/codieRuntimeInstall.js +108 -23
- package/dist/codieStartup.js +0 -3
- package/dist/codieUsage.js +38 -41
- package/dist/commands/ask.js +0 -3
- package/dist/commands/capture.js +0 -2
- package/dist/commands/createTicket.js +0 -10
- package/dist/commands/doctor.js +41 -82
- package/dist/commands/inbox.js +0 -2
- package/dist/commands/library.js +0 -3
- package/dist/commands/pack.js +573 -0
- package/dist/commands/ping.js +0 -2
- package/dist/commands/pull.js +6 -10
- package/dist/commands/push.js +2 -12
- package/dist/commands/react.js +0 -2
- package/dist/commands/reverseTicket.js +0 -33
- package/dist/commands/search.js +0 -4
- package/dist/commands/send.js +0 -5
- package/dist/commands/share.js +0 -4
- package/dist/commands/shared.js +0 -35
- package/dist/commands/traces.js +280 -0
- package/dist/configDir.js +0 -10
- package/dist/connect.js +21 -77
- package/dist/connectFlow.js +0 -9
- package/dist/copilotHooks.js +395 -0
- package/dist/copilotInstallation.js +64 -0
- package/dist/cursorHooks.js +40 -17
- package/dist/cursorLifecycle.js +109 -0
- package/dist/detection.js +0 -30
- package/dist/harnessDirs.js +73 -0
- package/dist/hook.js +193 -316
- package/dist/inboxFormat.js +0 -24
- package/dist/launchContext.js +150 -0
- package/dist/launcher.js +140 -0
- package/dist/limitEvent.js +41 -35
- package/dist/limitEventReporter.js +1 -1
- package/dist/mcp.js +3 -77
- package/dist/nativeSteering.js +24 -0
- package/dist/packs/codie.js +182 -0
- package/dist/packs/harnesses.js +374 -0
- package/dist/packs/hookGate.js +256 -0
- package/dist/packs/install.js +285 -0
- package/dist/packs/manifest.js +126 -0
- package/dist/packs/paths.js +81 -0
- package/dist/packs/shim.js +214 -0
- package/dist/packs/store.js +155 -0
- package/dist/packs/sync.js +170 -0
- package/dist/prUrl.js +0 -5
- package/dist/repoResolver.js +0 -19
- package/dist/secret.js +0 -3
- package/dist/security.js +0 -20
- package/dist/securityDeepScan.js +1 -14
- package/dist/securityDoctor.js +0 -2
- package/dist/securityFeature.js +0 -1
- package/dist/securityInstall.js +6 -13
- package/dist/securityInventory.js +23 -13
- package/dist/securityPilot.js +0 -2
- package/dist/securityPolicy.js +0 -7
- package/dist/selfUpdate.js +331 -0
- package/dist/skillMarker.js +23 -0
- package/dist/subagents.js +135 -0
- package/dist/teamSkillContext.js +10 -0
- package/dist/transcriptModels.js +6 -8
- package/dist/upgradeNudge.js +0 -30
- package/dist/utils.js +286 -733
- package/dist/version.js +0 -10
- package/dist/versionCheck.js +0 -33
- package/package.json +7 -6
- package/dist/backup/cache.d.ts +0 -14
- package/dist/backup/match.d.ts +0 -2
- package/dist/backup/run.d.ts +0 -25
- package/dist/captureExclusions.d.ts +0 -30
- package/dist/captureLog.d.ts +0 -20
- package/dist/captureReadiness.d.ts +0 -65
- package/dist/captureSignals.d.ts +0 -19
- package/dist/cli.d.ts +0 -16
- package/dist/codexHookTrust.d.ts +0 -34
- package/dist/codexLimitScan.d.ts +0 -64
- package/dist/codie.d.ts +0 -2
- package/dist/codieBrandInstall.d.ts +0 -11
- package/dist/codieLauncher.d.ts +0 -86
- package/dist/codieRuntime.d.ts +0 -29
- package/dist/codieRuntimeInstall.d.ts +0 -28
- package/dist/codieStartup.d.ts +0 -26
- package/dist/codieUsage.d.ts +0 -57
- package/dist/commands/ask.d.ts +0 -1
- package/dist/commands/capture.d.ts +0 -14
- package/dist/commands/createTicket.d.ts +0 -27
- package/dist/commands/delete.d.ts +0 -1
- package/dist/commands/doctor.d.ts +0 -1
- package/dist/commands/inbox.d.ts +0 -3
- package/dist/commands/library.d.ts +0 -2
- package/dist/commands/note.d.ts +0 -1
- package/dist/commands/ping.d.ts +0 -1
- package/dist/commands/promote.d.ts +0 -1
- package/dist/commands/pull.d.ts +0 -2
- package/dist/commands/push.d.ts +0 -33
- package/dist/commands/react.d.ts +0 -2
- package/dist/commands/reverseTicket.d.ts +0 -2
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/security.d.ts +0 -1
- package/dist/commands/send.d.ts +0 -2
- package/dist/commands/share.d.ts +0 -2
- package/dist/commands/shared.d.ts +0 -64
- package/dist/configDir.d.ts +0 -1
- package/dist/connect.d.ts +0 -1
- package/dist/connectFlow.d.ts +0 -13
- package/dist/cursorHooks.d.ts +0 -23
- package/dist/detection.d.ts +0 -30
- package/dist/hook.d.ts +0 -6
- package/dist/inboxFormat.d.ts +0 -38
- package/dist/limitEvent.d.ts +0 -16
- package/dist/limitEventReporter.d.ts +0 -21
- package/dist/mcp.d.ts +0 -12
- package/dist/prUrl.d.ts +0 -9
- package/dist/repoResolver.d.ts +0 -17
- package/dist/secret.d.ts +0 -1
- package/dist/security.d.ts +0 -102
- package/dist/securityDeepScan.d.ts +0 -41
- package/dist/securityDoctor.d.ts +0 -32
- package/dist/securityFeature.d.ts +0 -5
- package/dist/securityInstall.d.ts +0 -63
- package/dist/securityInventory.d.ts +0 -54
- package/dist/securityPilot.d.ts +0 -19
- package/dist/securityPolicy.d.ts +0 -33
- package/dist/securitySession.d.ts +0 -6
- package/dist/transcriptModels.d.ts +0 -18
- package/dist/upgradeNudge.d.ts +0 -25
- package/dist/utils.d.ts +0 -346
- package/dist/version.d.ts +0 -1
- package/dist/versionCheck.d.ts +0 -68
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.inspectCopilotHooks = inspectCopilotHooks;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const copilotHooks_1 = require("./copilotHooks");
|
|
40
|
+
const detection_1 = require("./detection");
|
|
41
|
+
function inspectCopilotHooks(file = path.join((0, copilotHooks_1.copilotHome)(), "hooks", "codiedev.json"), security = false) {
|
|
42
|
+
if (!fs.existsSync(file))
|
|
43
|
+
return { status: "not-installed", detail: `${file} not found` };
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
46
|
+
const expected = security
|
|
47
|
+
? [["userPromptSubmitted", "discover-copilot"], ["preToolUse", "security-pre-copilot"], ["postToolUse", "security-post-copilot"]]
|
|
48
|
+
: [["sessionStart", "session-start-copilot"], ["agentStop", "backup-copilot"], ["sessionEnd", "capture-copilot"], ["errorOccurred", "limit-copilot"]];
|
|
49
|
+
const missing = expected.filter(([event, subcommand]) => {
|
|
50
|
+
const entries = parsed.hooks?.[event];
|
|
51
|
+
return !Array.isArray(entries) || !entries.some((entry) => {
|
|
52
|
+
const commands = [entry.bash ?? entry.command, entry.powershell ?? entry.command];
|
|
53
|
+
return commands.every((command) => typeof command === "string"
|
|
54
|
+
&& (0, detection_1.isCodiedevHookCommand)(command) && command.trim().endsWith(subcommand));
|
|
55
|
+
});
|
|
56
|
+
}).map(([event]) => event);
|
|
57
|
+
if (parsed.version !== 1 || missing.length)
|
|
58
|
+
return { status: "fail", detail: `invalid or missing hooks: ${missing.join(", ") || "version"}` };
|
|
59
|
+
return { status: "pass", detail: security ? "prompt guard and tool telemetry hooks installed" : "session start, backup, capture and limit hooks installed" };
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return { status: "fail", detail: "invalid Copilot hook configuration" };
|
|
63
|
+
}
|
|
64
|
+
}
|
package/dist/cursorHooks.js
CHANGED
|
@@ -5,10 +5,8 @@ exports.normalizeCursorTranscript = normalizeCursorTranscript;
|
|
|
5
5
|
exports.isCursorTranscriptEmpty = isCursorTranscriptEmpty;
|
|
6
6
|
exports.cursorPreToolBlockResponse = cursorPreToolBlockResponse;
|
|
7
7
|
exports.cursorPromptBlockResponse = cursorPromptBlockResponse;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* the translation at the process boundary so the shared capture/security
|
|
11
|
-
* pipeline never has to guess which surface produced an event. */
|
|
8
|
+
exports.cursorTranscriptHasUsage = cursorTranscriptHasUsage;
|
|
9
|
+
exports.cursorObservedModel = cursorObservedModel;
|
|
12
10
|
function normalizeCursorHookInput(input) {
|
|
13
11
|
const sessionId = firstString(input.session_id, input.sessionId, input.conversation_id);
|
|
14
12
|
const roots = Array.isArray(input.workspace_roots)
|
|
@@ -29,9 +27,6 @@ function normalizeCursorHookInput(input) {
|
|
|
29
27
|
...(duration !== undefined ? { duration_ms: duration } : {}),
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
|
-
/** Cursor stores JSONL message roles in `role`; the shared capture pipeline
|
|
33
|
-
* uses Claude's top-level `type` discriminator. Preserve all original fields
|
|
34
|
-
* and add only that discriminator so the existing parsers see real messages. */
|
|
35
30
|
function normalizeCursorTranscript(content) {
|
|
36
31
|
return content
|
|
37
32
|
.split("\n")
|
|
@@ -40,23 +35,27 @@ function normalizeCursorTranscript(content) {
|
|
|
40
35
|
return line;
|
|
41
36
|
try {
|
|
42
37
|
const entry = JSON.parse(line);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
-
|
|
38
|
+
const type = entry.type ?? entry.role;
|
|
39
|
+
if (type !== "user" && type !== "assistant")
|
|
40
|
+
return line;
|
|
41
|
+
const message = entry.message;
|
|
42
|
+
const content = Array.isArray(message?.content) ? message.content.map((block) => {
|
|
43
|
+
if (!block || block.type !== "tool_use")
|
|
44
|
+
return block;
|
|
45
|
+
const input = block.input ?? {};
|
|
46
|
+
const name = block.name === "Shell" ? "Bash" : block.name === "StrReplace" ? "Edit" : block.name;
|
|
47
|
+
return { ...block, name, input: { ...input,
|
|
48
|
+
...(typeof input.path === "string" && input.file_path === undefined ? { file_path: input.path } : {}),
|
|
49
|
+
} };
|
|
50
|
+
}) : message?.content;
|
|
51
|
+
return JSON.stringify({ ...entry, type, ...(message ? { message: { ...message, content } } : {}) });
|
|
47
52
|
}
|
|
48
53
|
catch {
|
|
49
|
-
// Preserve malformed/non-JSON lines; tolerant downstream parsers skip
|
|
50
|
-
// anything they cannot consume.
|
|
51
54
|
}
|
|
52
55
|
return line;
|
|
53
56
|
})
|
|
54
57
|
.join("\n");
|
|
55
58
|
}
|
|
56
|
-
/** Cursor may change its private JSONL record shape independently of the hook
|
|
57
|
-
* contract. Only a byte-empty snapshot is safe to discard; a non-empty file
|
|
58
|
-
* that the current normalizer cannot parse must still be uploaded for backend
|
|
59
|
-
* recovery and diagnosis. */
|
|
60
59
|
function isCursorTranscriptEmpty(content) {
|
|
61
60
|
return content.trim().length === 0;
|
|
62
61
|
}
|
|
@@ -79,3 +78,27 @@ function cursorPromptBlockResponse(reason) {
|
|
|
79
78
|
user_message: reason,
|
|
80
79
|
};
|
|
81
80
|
}
|
|
81
|
+
function cursorTranscriptHasUsage(content) {
|
|
82
|
+
return content.split("\n").some((line) => {
|
|
83
|
+
try {
|
|
84
|
+
const usage = JSON.parse(line).message?.usage;
|
|
85
|
+
return usage && ["input_tokens", "output_tokens", "cache_read_input_tokens", "cache_creation_input_tokens"]
|
|
86
|
+
.some((key) => typeof usage[key] === "number" && Number.isFinite(usage[key]));
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function cursorObservedModel(content) {
|
|
94
|
+
let model;
|
|
95
|
+
for (const line of content.split("\n")) {
|
|
96
|
+
try {
|
|
97
|
+
const event = JSON.parse(line);
|
|
98
|
+
if (event.subtype === "cursor_model" && typeof event.model === "string")
|
|
99
|
+
model = event.model;
|
|
100
|
+
}
|
|
101
|
+
catch { }
|
|
102
|
+
}
|
|
103
|
+
return model;
|
|
104
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.recordCursorLifecycle = recordCursorLifecycle;
|
|
37
|
+
exports.cursorLifecycleRecords = cursorLifecycleRecords;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const crypto = __importStar(require("crypto"));
|
|
41
|
+
const configDir_1 = require("./configDir");
|
|
42
|
+
const limitEvent_1 = require("./limitEvent");
|
|
43
|
+
function fileFor(sessionId) {
|
|
44
|
+
const key = crypto.createHash("sha256").update(sessionId).digest("hex");
|
|
45
|
+
return path.join((0, configDir_1.codiedevStateDir)(), "cursor-lifecycle", `${key}.json`);
|
|
46
|
+
}
|
|
47
|
+
function recordCursorLifecycle(input, final) {
|
|
48
|
+
if (typeof input.session_id !== "string")
|
|
49
|
+
return;
|
|
50
|
+
const status = input.status ?? input.reason;
|
|
51
|
+
const file = fileFor(input.session_id);
|
|
52
|
+
let state = { ids: [] };
|
|
53
|
+
try {
|
|
54
|
+
state = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
55
|
+
}
|
|
56
|
+
catch { }
|
|
57
|
+
const model = typeof input.model_id === "string" && input.model_id.trim() ? input.model_id
|
|
58
|
+
: typeof input.model === "string" && input.model.trim() ? input.model : undefined;
|
|
59
|
+
if (model)
|
|
60
|
+
state.model = model;
|
|
61
|
+
const event = typeof input.hook_event_name === "string" ? input.hook_event_name : final ? "sessionEnd" : "stop";
|
|
62
|
+
if (event !== "sessionEnd" || !state.observations?.length) {
|
|
63
|
+
const timestamp = new Date().toISOString();
|
|
64
|
+
state.observations = [...(state.observations ?? []), { event, timestamp, ...(model ? { model } : {}) }].slice(-1000);
|
|
65
|
+
}
|
|
66
|
+
const limit = event === "postToolUse" || event === "postToolUseFailure" ? null : (0, limitEvent_1.parseNativeLimitError)(input);
|
|
67
|
+
if (limit) {
|
|
68
|
+
const generationId = typeof input.generation_id === "string" ? input.generation_id : undefined;
|
|
69
|
+
const last = state.limits?.at(-1);
|
|
70
|
+
const retry = last && (generationId ? last.generationId === generationId
|
|
71
|
+
: final && state.lastStatus === "error" && last.reason === limit.reason && last.resetText === limit.resetText);
|
|
72
|
+
if (!retry)
|
|
73
|
+
state.limits = [...(state.limits ?? []), { ...limit, ...(generationId ? { generationId } : {}) }].slice(-1000);
|
|
74
|
+
}
|
|
75
|
+
if (event === "subagentStart" && typeof input.subagent_id === "string") {
|
|
76
|
+
state.subagents = [...new Set([...(state.subagents ?? []), input.subagent_id])].slice(-1000);
|
|
77
|
+
}
|
|
78
|
+
if (event === "postToolUseFailure" && input.failure_type === "permission_denied") {
|
|
79
|
+
const rejectionId = typeof input.tool_use_id === "string" ? input.tool_use_id : `${Date.now()}-${state.rejections?.length ?? 0}`;
|
|
80
|
+
state.rejections = [...new Set([...(state.rejections ?? []), rejectionId])].slice(-1000);
|
|
81
|
+
}
|
|
82
|
+
const aborted = status === "aborted" || input.is_interrupt === true;
|
|
83
|
+
const id = typeof input.generation_id === "string" ? input.generation_id
|
|
84
|
+
: `${Date.now()}-${state.ids.length}`;
|
|
85
|
+
if (aborted && !(final && state.lastStatus === "aborted") && !state.ids.includes(id))
|
|
86
|
+
state.ids.push(id);
|
|
87
|
+
if (typeof status === "string")
|
|
88
|
+
state.lastStatus = status;
|
|
89
|
+
state.ids = state.ids.slice(-1000);
|
|
90
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
91
|
+
fs.writeFileSync(file, JSON.stringify(state), { mode: 0o600 });
|
|
92
|
+
}
|
|
93
|
+
function cursorLifecycleRecords(sessionId) {
|
|
94
|
+
if (!sessionId)
|
|
95
|
+
return "";
|
|
96
|
+
try {
|
|
97
|
+
const state = JSON.parse(fs.readFileSync(fileFor(sessionId), "utf8"));
|
|
98
|
+
return [...(state.observations ?? []).map((observation) => JSON.stringify({ type: "system", subtype: "cursor_hook_observation", ...observation })),
|
|
99
|
+
...(state.model ? [JSON.stringify({ type: "system", subtype: "cursor_model", model: state.model })] : []),
|
|
100
|
+
...(state.rejections ?? []).map(id => JSON.stringify({ type: "agent.rejection", id })),
|
|
101
|
+
...(state.subagents?.length ? [JSON.stringify({ type: "cursor.subagent_summary", count: state.subagents.length, truncated: state.subagents.length >= 1000 })] : []),
|
|
102
|
+
...state.ids.map((id) => JSON.stringify({ type: "agent.interruption", id })),
|
|
103
|
+
...(state.limits ?? []).map(({ generationId: _generationId, ...event }) => JSON.stringify({ type: "agent.limit", ...event })),
|
|
104
|
+
].join("\n");
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return "";
|
|
108
|
+
}
|
|
109
|
+
}
|
package/dist/detection.js
CHANGED
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Pure detection helpers — runtime probes (fs / PATH lookup) live in utils.ts
|
|
3
|
-
// and feed these. Splitting them out makes the truth-table testable without
|
|
4
|
-
// mocking fs or process.
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.detectClaudeCode = detectClaudeCode;
|
|
7
4
|
exports.isCodiedevHookCommand = isCodiedevHookCommand;
|
|
8
|
-
/**
|
|
9
|
-
* Claude Code is "installed" if either ~/.claude exists (the user has
|
|
10
|
-
* launched the app at least once) OR the `claude` binary is on PATH (the
|
|
11
|
-
* user installed via npm/brew but hasn't launched yet). Either signal is
|
|
12
|
-
* sufficient — we want to wire up the hook the moment the user has
|
|
13
|
-
* obviously committed to the tool.
|
|
14
|
-
*/
|
|
15
5
|
function detectClaudeCode(probe) {
|
|
16
6
|
return probe.dirExists || probe.binOnPath;
|
|
17
7
|
}
|
|
18
|
-
/**
|
|
19
|
-
* True iff `cmd` looks like a hook command codiedev itself wrote. Used
|
|
20
|
-
* both by the install filter (so `connect` replaces the existing entry
|
|
21
|
-
* instead of stacking another one) and by `codiedev doctor` (so it can
|
|
22
|
-
* grade whether the hook is wired up).
|
|
23
|
-
*
|
|
24
|
-
* Must match every form codiedev can write:
|
|
25
|
-
* - Legacy `npx codiedev-hook <subcommand>`
|
|
26
|
-
* - Absolute path from npm-registry install:
|
|
27
|
-
* `<node> /.../node_modules/codiedev/dist/hook.js <subcommand>`
|
|
28
|
-
* - Absolute path from `npm link` dev install (the monorepo folder
|
|
29
|
-
* is named `codiedev-cli`, not `codiedev`):
|
|
30
|
-
* `<node> /.../codiedev-cli/dist/hook.js <subcommand>`
|
|
31
|
-
*
|
|
32
|
-
* The `codiedev[^/\\]*` allows the trailing `-cli` (or any future suffix)
|
|
33
|
-
* without matching unrelated paths like `notcodiedev/dist/hook.js`.
|
|
34
|
-
*/
|
|
35
8
|
function isCodiedevHookCommand(cmd) {
|
|
36
9
|
if (!cmd)
|
|
37
10
|
return false;
|
|
38
11
|
if (cmd.includes("codiedev-hook"))
|
|
39
12
|
return true;
|
|
40
|
-
// Anchor at a path separator (or string start) so we don't match
|
|
41
|
-
// unrelated paths like `notcodiedev/dist/hook.js` that happen to contain
|
|
42
|
-
// the substring `codiedev`.
|
|
43
13
|
return /(?:^|[\\/])codiedev[^/\\]*[\\/]dist[\\/]hook/.test(cmd);
|
|
44
14
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.claudeConfigDir = claudeConfigDir;
|
|
37
|
+
exports.claudeUserConfigPath = claudeUserConfigPath;
|
|
38
|
+
exports.codexHome = codexHome;
|
|
39
|
+
exports.openCodeConfigDir = openCodeConfigDir;
|
|
40
|
+
exports.displayPath = displayPath;
|
|
41
|
+
exports.claudeConfigDirInUse = claudeConfigDirInUse;
|
|
42
|
+
exports.codexHomeInUse = codexHomeInUse;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
function override(value) {
|
|
47
|
+
const trimmed = value?.trim();
|
|
48
|
+
return trimmed ? path.resolve(trimmed) : undefined;
|
|
49
|
+
}
|
|
50
|
+
function claudeConfigDir(env = process.env, home = os.homedir()) {
|
|
51
|
+
return override(env.CLAUDE_CONFIG_DIR) ?? path.join(home, ".claude");
|
|
52
|
+
}
|
|
53
|
+
function claudeUserConfigPath(env = process.env, home = os.homedir()) {
|
|
54
|
+
const dir = override(env.CLAUDE_CONFIG_DIR);
|
|
55
|
+
return dir ? path.join(dir, ".claude.json") : path.join(home, ".claude.json");
|
|
56
|
+
}
|
|
57
|
+
function codexHome(env = process.env, home = os.homedir()) {
|
|
58
|
+
return override(env.CODEX_HOME) ?? path.join(home, ".codex");
|
|
59
|
+
}
|
|
60
|
+
function openCodeConfigDir(env = process.env, home = os.homedir()) {
|
|
61
|
+
return path.join(override(env.XDG_CONFIG_HOME) ?? path.join(home, ".config"), "opencode");
|
|
62
|
+
}
|
|
63
|
+
function displayPath(p, home = os.homedir()) {
|
|
64
|
+
return p === home || p.startsWith(home + path.sep) ? "~" + p.slice(home.length) : p;
|
|
65
|
+
}
|
|
66
|
+
const CLAUDE_USAGE_MARKERS = ["projects", "history.jsonl", "sessions", "statsig", "todos", "shell-snapshots"];
|
|
67
|
+
function claudeConfigDirInUse(dir = claudeConfigDir(), exists = fs.existsSync) {
|
|
68
|
+
return CLAUDE_USAGE_MARKERS.some((m) => exists(path.join(dir, m)));
|
|
69
|
+
}
|
|
70
|
+
const CODEX_USAGE_MARKERS = ["sessions", "history.jsonl", "auth.json"];
|
|
71
|
+
function codexHomeInUse(dir = codexHome(), exists = fs.existsSync) {
|
|
72
|
+
return CODEX_USAGE_MARKERS.some((m) => exists(path.join(dir, m)));
|
|
73
|
+
}
|