@fyso/awareness-framework 0.1.0 → 0.2.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/docs/hooks-and-scheduling.md +8 -2
- package/package.json +1 -1
- package/src/cli.js +23 -0
|
@@ -31,13 +31,19 @@ These files are private operational state. Do not commit them.
|
|
|
31
31
|
|
|
32
32
|
| Lifecycle point | Command | Purpose |
|
|
33
33
|
|-----------------|---------|---------|
|
|
34
|
-
| Session start or resume | `awareness hook run --tool TOOL --event session-start` | Ensure private files exist
|
|
34
|
+
| Session start or resume | `awareness hook run --tool TOOL --event session-start` | Ensure private files exist, record that the agent refreshed awareness, and print the Current Focus so the host injects it as context. |
|
|
35
35
|
| Stop or session end | `awareness hook run --tool TOOL --event stop` | Record that the agent reached an idle or handoff boundary. |
|
|
36
36
|
| Pre-compaction | `awareness hook run --tool TOOL --event pre-compact` | Record a compaction boundary before context is summarized. |
|
|
37
|
-
| Post-compaction | `awareness hook run --tool TOOL --event post-compact` | Record that the new compacted context may need `awareness refresh
|
|
37
|
+
| Post-compaction | `awareness hook run --tool TOOL --event post-compact` | Record that the new compacted context may need `awareness refresh`, and re-print the Current Focus so it survives compaction. |
|
|
38
38
|
|
|
39
39
|
Hooks should not append daily worklog entries on every lifecycle event. The worklog is for human-relevant progress with task IDs and evidence.
|
|
40
40
|
|
|
41
|
+
## Context Injection
|
|
42
|
+
|
|
43
|
+
`session-start` and `post-compact` are **context-injection events**: hosts such as Claude Code append the hook's stdout to the agent's context. For these events `awareness hook run` always prints the `Current Focus` block (framed as a load-this-first instruction), so the agent actively loads its focus instead of relying on a passive, possibly stale file import.
|
|
44
|
+
|
|
45
|
+
`--quiet` only suppresses the diagnostic lines (`Hook recorded`, `Runtime log`, `Warnings`). It does **not** suppress the focus payload — the installed hooks pass `--quiet` precisely so the only thing reaching the agent's context is the focus itself. Non-injection events (`stop`, `session-end`, `pre-compact`) never print the focus.
|
|
46
|
+
|
|
41
47
|
## Scheduled Cadence
|
|
42
48
|
|
|
43
49
|
| Cadence | Command | Purpose |
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -434,6 +434,11 @@ function hookCommand(ctx, subcommand, opts) {
|
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
+
// Events whose stdout the host agent injects into its context. For these we
|
|
438
|
+
// always emit the Current Focus so the agent actually loads the protocol state,
|
|
439
|
+
// even under --quiet (which only suppresses diagnostic noise, not the payload).
|
|
440
|
+
const CONTEXT_INJECTION_EVENTS = new Set(['session-start', 'post-compact']);
|
|
441
|
+
|
|
437
442
|
function hookRunCommand(ctx, opts) {
|
|
438
443
|
const home = agentsHome(ctx, opts);
|
|
439
444
|
const today = todayParts(ctx);
|
|
@@ -455,9 +460,27 @@ function hookRunCommand(ctx, opts) {
|
|
|
455
460
|
out(ctx, warnings.length ? `Warnings: ${warnings.length}` : 'Warnings: none');
|
|
456
461
|
}
|
|
457
462
|
|
|
463
|
+
if (CONTEXT_INJECTION_EVENTS.has(event)) {
|
|
464
|
+
emitFocusContext(ctx, home);
|
|
465
|
+
}
|
|
466
|
+
|
|
458
467
|
return 0;
|
|
459
468
|
}
|
|
460
469
|
|
|
470
|
+
// Print the Current Focus as injectable context for the host agent. Framed as
|
|
471
|
+
// an instruction so the agent treats it as actionable, not background noise.
|
|
472
|
+
function emitFocusContext(ctx, home) {
|
|
473
|
+
const currentPath = awarenessPath(home);
|
|
474
|
+
if (!fs.existsSync(currentPath)) return;
|
|
475
|
+
const focus = extractSection(fs.readFileSync(currentPath, 'utf8'), 'Current Focus').trim();
|
|
476
|
+
if (!focus) return;
|
|
477
|
+
out(ctx, '[awareness] Load this before doing work — current focus:');
|
|
478
|
+
out(ctx, '');
|
|
479
|
+
out(ctx, focus);
|
|
480
|
+
out(ctx, '');
|
|
481
|
+
out(ctx, 'Follow the awareness protocol; run `awareness handoff` before yielding control.');
|
|
482
|
+
}
|
|
483
|
+
|
|
461
484
|
function hookInstallCommand(ctx, opts) {
|
|
462
485
|
const tool = opts.tool || 'all';
|
|
463
486
|
const userHome = userHomePath(ctx, opts);
|