@opencode_weave/weave 0.6.1 → 0.6.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { WorkState, PlanProgress } from "./types";
|
|
2
2
|
export type { ValidationResult, ValidationIssue, ValidationSeverity, ValidationCategory } from "./validation-types";
|
|
3
3
|
export { WEAVE_DIR, WORK_STATE_FILE, WORK_STATE_PATH, PLANS_DIR } from "./constants";
|
|
4
|
-
export { readWorkState, writeWorkState, clearWorkState, appendSessionId, createWorkState, findPlans, getPlanProgress, getPlanName, getHeadSha, } from "./storage";
|
|
4
|
+
export { readWorkState, writeWorkState, clearWorkState, appendSessionId, createWorkState, findPlans, getPlanProgress, getPlanName, getHeadSha, pauseWork, resumeWork, } from "./storage";
|
|
5
5
|
export { validatePlan } from "./validation";
|
|
@@ -41,3 +41,13 @@ export declare function getPlanProgress(planPath: string): PlanProgress;
|
|
|
41
41
|
* Extract plan name from file path (basename minus .md extension).
|
|
42
42
|
*/
|
|
43
43
|
export declare function getPlanName(planPath: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Pause work by setting paused: true in the work state.
|
|
46
|
+
* Returns false if no state exists (e.g., no active plan).
|
|
47
|
+
*/
|
|
48
|
+
export declare function pauseWork(directory: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Resume work by setting paused: false in the work state.
|
|
51
|
+
* Returns false if no state exists.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resumeWork(directory: string): boolean;
|
|
@@ -15,6 +15,8 @@ export interface WorkState {
|
|
|
15
15
|
agent?: string;
|
|
16
16
|
/** Git HEAD SHA at the time work started (absent if not a git repo) */
|
|
17
17
|
start_sha?: string;
|
|
18
|
+
/** Whether work has been paused by a user interrupt; continuation is suppressed while true */
|
|
19
|
+
paused?: boolean;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Progress snapshot from counting checkboxes in a plan file.
|
package/dist/index.js
CHANGED
|
@@ -1990,6 +1990,20 @@ function getPlanProgress(planPath) {
|
|
|
1990
1990
|
function getPlanName(planPath) {
|
|
1991
1991
|
return basename(planPath, ".md");
|
|
1992
1992
|
}
|
|
1993
|
+
function pauseWork(directory) {
|
|
1994
|
+
const state = readWorkState(directory);
|
|
1995
|
+
if (!state)
|
|
1996
|
+
return false;
|
|
1997
|
+
state.paused = true;
|
|
1998
|
+
return writeWorkState(directory, state);
|
|
1999
|
+
}
|
|
2000
|
+
function resumeWork(directory) {
|
|
2001
|
+
const state = readWorkState(directory);
|
|
2002
|
+
if (!state)
|
|
2003
|
+
return false;
|
|
2004
|
+
state.paused = false;
|
|
2005
|
+
return writeWorkState(directory, state);
|
|
2006
|
+
}
|
|
1993
2007
|
// src/features/work-state/validation.ts
|
|
1994
2008
|
import { readFileSync as readFileSync5, existsSync as existsSync6 } from "fs";
|
|
1995
2009
|
import { resolve as resolve2, sep } from "path";
|
|
@@ -2299,6 +2313,7 @@ Tell the user to fix the plan file and run /start-work again.`
|
|
|
2299
2313
|
};
|
|
2300
2314
|
}
|
|
2301
2315
|
appendSessionId(directory, sessionId);
|
|
2316
|
+
resumeWork(directory);
|
|
2302
2317
|
const resumeContext = buildResumeContext(existingState.active_plan, existingState.plan_name, progress, existingState.start_sha);
|
|
2303
2318
|
if (validation.warnings.length > 0) {
|
|
2304
2319
|
return {
|
|
@@ -2511,6 +2526,9 @@ function checkContinuation(input) {
|
|
|
2511
2526
|
if (!state) {
|
|
2512
2527
|
return { continuationPrompt: null };
|
|
2513
2528
|
}
|
|
2529
|
+
if (state.paused) {
|
|
2530
|
+
return { continuationPrompt: null };
|
|
2531
|
+
}
|
|
2514
2532
|
const progress = getPlanProgress(state.active_plan);
|
|
2515
2533
|
if (progress.isComplete) {
|
|
2516
2534
|
return { continuationPrompt: null };
|
|
@@ -2605,8 +2623,7 @@ function clearSession2(sessionId) {
|
|
|
2605
2623
|
}
|
|
2606
2624
|
// src/plugin/plugin-interface.ts
|
|
2607
2625
|
function createPluginInterface(args) {
|
|
2608
|
-
const { pluginConfig, hooks, tools, configHandler, agents, client } = args;
|
|
2609
|
-
let pendingInterrupt = false;
|
|
2626
|
+
const { pluginConfig, hooks, tools, configHandler, agents, client, directory = "" } = args;
|
|
2610
2627
|
return {
|
|
2611
2628
|
tool: tools,
|
|
2612
2629
|
config: async (config) => {
|
|
@@ -2715,34 +2732,29 @@ ${result.contextInjection}`;
|
|
|
2715
2732
|
if (event.type === "tui.command.execute") {
|
|
2716
2733
|
const evt = event;
|
|
2717
2734
|
if (evt.properties?.command === "session.interrupt") {
|
|
2718
|
-
|
|
2719
|
-
log("[work-continuation] User interrupt detected —
|
|
2735
|
+
pauseWork(directory);
|
|
2736
|
+
log("[work-continuation] User interrupt detected — work paused");
|
|
2720
2737
|
}
|
|
2721
2738
|
}
|
|
2722
2739
|
if (hooks.workContinuation && event.type === "session.idle") {
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
});
|
|
2739
|
-
log("[work-continuation] Injected continuation prompt", { sessionId });
|
|
2740
|
-
} catch (err) {
|
|
2741
|
-
log("[work-continuation] Failed to inject continuation", { sessionId, error: String(err) });
|
|
2742
|
-
}
|
|
2743
|
-
} else if (result.continuationPrompt) {
|
|
2744
|
-
log("[work-continuation] continuationPrompt available but no client", { sessionId });
|
|
2740
|
+
const evt = event;
|
|
2741
|
+
const sessionId = evt.properties?.sessionID ?? "";
|
|
2742
|
+
if (sessionId) {
|
|
2743
|
+
const result = hooks.workContinuation(sessionId);
|
|
2744
|
+
if (result.continuationPrompt && client) {
|
|
2745
|
+
try {
|
|
2746
|
+
await client.session.promptAsync({
|
|
2747
|
+
path: { id: sessionId },
|
|
2748
|
+
body: {
|
|
2749
|
+
parts: [{ type: "text", text: result.continuationPrompt }]
|
|
2750
|
+
}
|
|
2751
|
+
});
|
|
2752
|
+
log("[work-continuation] Injected continuation prompt", { sessionId });
|
|
2753
|
+
} catch (err) {
|
|
2754
|
+
log("[work-continuation] Failed to inject continuation", { sessionId, error: String(err) });
|
|
2745
2755
|
}
|
|
2756
|
+
} else if (result.continuationPrompt) {
|
|
2757
|
+
log("[work-continuation] continuationPrompt available but no client", { sessionId });
|
|
2746
2758
|
}
|
|
2747
2759
|
}
|
|
2748
2760
|
}
|
|
@@ -2808,7 +2820,8 @@ var WeavePlugin = async (ctx) => {
|
|
|
2808
2820
|
tools: toolsResult.tools,
|
|
2809
2821
|
configHandler: managers.configHandler,
|
|
2810
2822
|
agents: managers.agents,
|
|
2811
|
-
client: ctx.client
|
|
2823
|
+
client: ctx.client,
|
|
2824
|
+
directory: ctx.directory
|
|
2812
2825
|
});
|
|
2813
2826
|
};
|
|
2814
2827
|
var src_default = WeavePlugin;
|