@dv.nghiem/flowdeck 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/approval-hook.d.ts +2 -6
- package/dist/hooks/approval-hook.d.ts.map +1 -1
- package/dist/hooks/decision-trace-hook.d.ts.map +1 -1
- package/dist/hooks/session-idle-hook.d.ts.map +1 -1
- package/dist/hooks/telemetry-hook.d.ts +5 -11
- package/dist/hooks/telemetry-hook.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -39
- package/package.json +1 -1
|
@@ -3,11 +3,7 @@ export declare function approvalHook(context: {
|
|
|
3
3
|
}, toolInput: {
|
|
4
4
|
name?: string;
|
|
5
5
|
tool?: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
parts?: Array<{
|
|
9
|
-
type: string;
|
|
10
|
-
text: string;
|
|
11
|
-
}>;
|
|
6
|
+
}, output: {
|
|
7
|
+
args?: Record<string, unknown>;
|
|
12
8
|
}): Promise<void>;
|
|
13
9
|
//# sourceMappingURL=approval-hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/approval-hook.ts"],"names":[],"mappings":"AAUA,wBAAsB,YAAY,CAChC,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/B,SAAS,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"approval-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/approval-hook.ts"],"names":[],"mappings":"AAUA,wBAAsB,YAAY,CAChC,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/B,SAAS,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3C,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACzC,OAAO,CAAC,IAAI,CAAC,CAgCf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decision-trace-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/decision-trace-hook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC1B,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACvB,MAAM,EAAE;IAAE,IAAI,EAAE,GAAG,CAAA;CAAE,GACpB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"decision-trace-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/decision-trace-hook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC1B,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACvB,MAAM,EAAE;IAAE,IAAI,EAAE,GAAG,CAAA;CAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-idle-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/session-idle-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAExD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE;IAAE,GAAG,EAAE;QAAE,GAAG,EAAE,CAAC,IAAI,EAAE;YAAE,IAAI,EAAE;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;KAAE,CAAA;CAAE,EAC5I,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"session-idle-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/session-idle-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAExD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE;IAAE,GAAG,EAAE;QAAE,GAAG,EAAE,CAAC,IAAI,EAAE;YAAE,IAAI,EAAE;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;KAAE,CAAA;CAAE,EAC5I,OAAO,EAAE,kBAAkB,uBAmC5B"}
|
|
@@ -3,12 +3,8 @@ export declare function telemetryHook(context: {
|
|
|
3
3
|
}, toolInput: {
|
|
4
4
|
name?: string;
|
|
5
5
|
tool?: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
parts?: Array<{
|
|
9
|
-
type: string;
|
|
10
|
-
text: string;
|
|
11
|
-
}>;
|
|
6
|
+
}, output: {
|
|
7
|
+
args?: Record<string, unknown>;
|
|
12
8
|
}): Promise<void>;
|
|
13
9
|
export declare function telemetryAfterHook(context: {
|
|
14
10
|
directory?: string;
|
|
@@ -16,10 +12,8 @@ export declare function telemetryAfterHook(context: {
|
|
|
16
12
|
name?: string;
|
|
17
13
|
tool?: string;
|
|
18
14
|
}, _output: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}>;
|
|
23
|
-
error?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
output?: string;
|
|
17
|
+
metadata?: unknown;
|
|
24
18
|
}): Promise<void>;
|
|
25
19
|
//# sourceMappingURL=telemetry-hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/telemetry-hook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telemetry-hook.d.ts","sourceRoot":"","sources":["../../src/hooks/telemetry-hook.ts"],"names":[],"mappings":"AAOA,wBAAsB,aAAa,CACjC,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/B,SAAS,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3C,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACzC,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/B,SAAS,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3C,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/D,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAqH/D,QAAA,MAAM,MAAM,EAAE,YAGb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1920,21 +1920,23 @@ async function decisionTraceHook(ctx, input, output) {
|
|
|
1920
1920
|
if (!filePath)
|
|
1921
1921
|
return;
|
|
1922
1922
|
const base = codebaseDir(ctx.directory);
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1923
|
+
try {
|
|
1924
|
+
if (!existsSync15(base))
|
|
1925
|
+
mkdirSync7(base, { recursive: true });
|
|
1926
|
+
const entry = {
|
|
1927
|
+
timestamp: new Date().toISOString(),
|
|
1928
|
+
file_path: filePath,
|
|
1929
|
+
change_type: input.tool === "write" ? "create" : "edit",
|
|
1930
|
+
rationale: output.args?.rationale ?? "(not provided \u2014 use decision-trace tool for richer records)",
|
|
1931
|
+
evidence: [],
|
|
1932
|
+
assumptions: [],
|
|
1933
|
+
alternatives_considered: [],
|
|
1934
|
+
risk_level: "unknown",
|
|
1935
|
+
auto_recorded: true
|
|
1936
|
+
};
|
|
1937
|
+
appendFileSync2(join14(base, "DECISIONS.jsonl"), JSON.stringify(entry) + `
|
|
1937
1938
|
`, "utf-8");
|
|
1939
|
+
} catch {}
|
|
1938
1940
|
}
|
|
1939
1941
|
|
|
1940
1942
|
// src/services/telemetry.ts
|
|
@@ -1959,19 +1961,27 @@ function appendEvent(dir, partial) {
|
|
|
1959
1961
|
}
|
|
1960
1962
|
|
|
1961
1963
|
// src/hooks/telemetry-hook.ts
|
|
1962
|
-
|
|
1963
|
-
async function telemetryHook(context, toolInput, _output) {
|
|
1964
|
+
async function telemetryHook(context, toolInput, output) {
|
|
1964
1965
|
const dir = context.directory ?? process.cwd();
|
|
1965
1966
|
const tool15 = toolInput.name ?? toolInput.tool ?? "unknown";
|
|
1966
|
-
const callKey = `${tool15}::${Date.now()}`;
|
|
1967
|
-
callStartTimes.set(callKey, Date.now());
|
|
1968
1967
|
appendEvent(dir, {
|
|
1969
1968
|
session_id: process.env.OPENCODE_SESSION_ID ?? "session-0",
|
|
1970
1969
|
run_id: process.env.OPENCODE_RUN_ID ?? "run-0",
|
|
1971
1970
|
event: "tool.call",
|
|
1972
1971
|
tool: tool15,
|
|
1973
1972
|
status: "ok",
|
|
1974
|
-
meta: { parameters:
|
|
1973
|
+
meta: { parameters: output.args ?? {} }
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1976
|
+
async function telemetryAfterHook(context, toolInput, _output) {
|
|
1977
|
+
const dir = context.directory ?? process.cwd();
|
|
1978
|
+
const tool15 = toolInput.name ?? toolInput.tool ?? "unknown";
|
|
1979
|
+
appendEvent(dir, {
|
|
1980
|
+
session_id: process.env.OPENCODE_SESSION_ID ?? "session-0",
|
|
1981
|
+
run_id: process.env.OPENCODE_RUN_ID ?? "run-0",
|
|
1982
|
+
event: "tool.complete",
|
|
1983
|
+
tool: tool15,
|
|
1984
|
+
status: "ok"
|
|
1975
1985
|
});
|
|
1976
1986
|
}
|
|
1977
1987
|
|
|
@@ -2034,13 +2044,13 @@ function checkApproval(dir, file_path, command) {
|
|
|
2034
2044
|
|
|
2035
2045
|
// src/hooks/approval-hook.ts
|
|
2036
2046
|
var WRITE_TOOLS = new Set(["write_file", "edit_file", "create_file", "apply_patch", "str_replace_editor", "write"]);
|
|
2037
|
-
async function approvalHook(context, toolInput,
|
|
2047
|
+
async function approvalHook(context, toolInput, output) {
|
|
2038
2048
|
const dir = context.directory ?? process.cwd();
|
|
2039
2049
|
const tool15 = toolInput.name ?? toolInput.tool ?? "";
|
|
2040
2050
|
if (!WRITE_TOOLS.has(tool15))
|
|
2041
2051
|
return;
|
|
2042
|
-
const
|
|
2043
|
-
const filePath = String(
|
|
2052
|
+
const args = output.args ?? {};
|
|
2053
|
+
const filePath = String(args.path ?? args.file_path ?? args.filename ?? "");
|
|
2044
2054
|
if (!filePath)
|
|
2045
2055
|
return;
|
|
2046
2056
|
if (!isSensitivePath(filePath))
|
|
@@ -2250,20 +2260,22 @@ function createFileTrackerHooks(tracker) {
|
|
|
2250
2260
|
// src/hooks/session-idle-hook.ts
|
|
2251
2261
|
function createSessionIdleHook(client, tracker) {
|
|
2252
2262
|
return async () => {
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2263
|
+
try {
|
|
2264
|
+
const edited = tracker.getEditedPaths();
|
|
2265
|
+
if (edited.length === 0)
|
|
2266
|
+
return;
|
|
2267
|
+
notifySessionIdle();
|
|
2268
|
+
const summary = `[FlowDeck] Session idle \u2014 ${edited.length} file(s) modified this session`;
|
|
2269
|
+
await client.app.log({ body: { service: "flowdeck", level: "info", message: summary } }).catch(() => {});
|
|
2270
|
+
const preview = edited.slice(0, 10);
|
|
2271
|
+
for (const f of preview) {
|
|
2272
|
+
await client.app.log({ body: { service: "flowdeck", level: "info", message: ` \u2022 ${f}` } }).catch(() => {});
|
|
2273
|
+
}
|
|
2274
|
+
if (edited.length > 10) {
|
|
2275
|
+
await client.app.log({ body: { service: "flowdeck", level: "info", message: ` \u2026 and ${edited.length - 10} more` } }).catch(() => {});
|
|
2276
|
+
}
|
|
2277
|
+
tracker.clear();
|
|
2278
|
+
} catch {}
|
|
2267
2279
|
};
|
|
2268
2280
|
}
|
|
2269
2281
|
|
|
@@ -2420,9 +2432,8 @@ var server = async (input, _options) => {
|
|
|
2420
2432
|
"file.edited": fileEdited,
|
|
2421
2433
|
"file.watcher.updated": fileWatcherUpdated,
|
|
2422
2434
|
"experimental.session.compacting": compactionHook,
|
|
2423
|
-
"permission.ask": async (
|
|
2424
|
-
notifyPermissionNeeded(
|
|
2425
|
-
return;
|
|
2435
|
+
"permission.ask": async (input2, _output) => {
|
|
2436
|
+
notifyPermissionNeeded(input2.title);
|
|
2426
2437
|
},
|
|
2427
2438
|
event: async ({ event }) => {
|
|
2428
2439
|
const type = event?.type ?? "";
|
|
@@ -2442,6 +2453,7 @@ var server = async (input, _options) => {
|
|
|
2442
2453
|
await decisionTraceHook({ directory }, toolInput, toolOutput);
|
|
2443
2454
|
},
|
|
2444
2455
|
"tool.execute.after": async (toolInput, toolOutput) => {
|
|
2456
|
+
await telemetryAfterHook({ directory }, toolInput, toolOutput);
|
|
2445
2457
|
await contextMonitor["tool.execute.after"](toolInput, toolOutput);
|
|
2446
2458
|
}
|
|
2447
2459
|
};
|