opencode-swarm 6.30.1 → 6.31.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/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +6606 -2568
- package/dist/commands/index.d.ts +4 -1
- package/dist/commands/registry.d.ts +160 -0
- package/dist/config/schema.d.ts +22 -0
- package/dist/hooks/curator-drift-advisory.test.d.ts +1 -0
- package/dist/hooks/curator-drift.d.ts +1 -1
- package/dist/hooks/delegation-ledger.d.ts +37 -0
- package/dist/hooks/delegation-ledger.test.d.ts +11 -0
- package/dist/hooks/scope-guard-throw-behavior.test.d.ts +15 -0
- package/dist/hooks/scope-guard.adversarial.test.d.ts +1 -0
- package/dist/hooks/scope-guard.d.ts +43 -0
- package/dist/hooks/scope-guard.test.d.ts +14 -0
- package/dist/hooks/self-review.d.ts +14 -0
- package/dist/hooks/self-review.test.d.ts +14 -0
- package/dist/hooks/slop-detector.adversarial.test.d.ts +1 -0
- package/dist/hooks/watchdog.integration.test.d.ts +9 -0
- package/dist/index.js +7447 -6623
- package/dist/tools/curator-analyze.d.ts +7 -0
- package/dist/tools/curator-analyze.test.d.ts +1 -0
- package/dist/tools/diff.d.ts +2 -2
- package/dist/tools/gitingest.d.ts +2 -2
- package/dist/tools/imports.d.ts +2 -2
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/knowledge-add.d.ts +2 -0
- package/dist/tools/knowledge-recall.d.ts +2 -0
- package/dist/tools/knowledge-remove.d.ts +2 -0
- package/dist/tools/knowledge-tools.integration.test.d.ts +1 -0
- package/dist/tools/lint.d.ts +1 -1
- package/dist/tools/phase-complete.d.ts +1 -1
- package/dist/tools/pre-check-batch.d.ts +1 -1
- package/dist/tools/retrieve-summary.d.ts +2 -2
- package/dist/tools/secretscan.d.ts +2 -2
- package/dist/tools/test-runner.d.ts +1 -1
- package/dist/tools/update-task-status.adversarial.test.d.ts +13 -0
- package/dist/tools/update-task-status.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { AgentDefinition } from '../agents';
|
|
1
|
+
import type { AgentDefinition } from '../agents/index.js';
|
|
2
2
|
export { handleAgentsCommand } from './agents';
|
|
3
3
|
export { handleAnalyzeCommand } from './analyze';
|
|
4
4
|
export { handleArchiveCommand } from './archive';
|
|
5
5
|
export { handleBenchmarkCommand } from './benchmark';
|
|
6
|
+
export { handleCheckpointCommand } from './checkpoint';
|
|
6
7
|
export { handleClarifyCommand } from './clarify';
|
|
7
8
|
export { handleConfigCommand } from './config';
|
|
8
9
|
export { handleCurateCommand } from './curate';
|
|
@@ -17,6 +18,8 @@ export { handleKnowledgeListCommand, handleKnowledgeMigrateCommand, handleKnowle
|
|
|
17
18
|
export { handlePlanCommand } from './plan';
|
|
18
19
|
export { handlePreflightCommand } from './preflight';
|
|
19
20
|
export { handlePromoteCommand } from './promote';
|
|
21
|
+
export type { CommandContext, CommandEntry, RegisteredCommand, } from './registry.js';
|
|
22
|
+
export { COMMAND_REGISTRY, resolveCommand, VALID_COMMANDS, } from './registry.js';
|
|
20
23
|
export { handleResetCommand } from './reset';
|
|
21
24
|
export { handleRetrieveCommand } from './retrieve';
|
|
22
25
|
export { handleRollbackCommand } from './rollback';
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { AgentDefinition } from '../agents/index.js';
|
|
2
|
+
export type CommandContext = {
|
|
3
|
+
directory: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
sessionID: string;
|
|
6
|
+
agents: Record<string, AgentDefinition>;
|
|
7
|
+
};
|
|
8
|
+
export type CommandResult = Promise<string>;
|
|
9
|
+
export type CommandEntry = {
|
|
10
|
+
handler: (ctx: CommandContext) => CommandResult;
|
|
11
|
+
/** Human-readable description shown in /swarm help and CLI --help */
|
|
12
|
+
description: string;
|
|
13
|
+
/** If true, this command is only accessible as a sub-key of a parent command */
|
|
14
|
+
subcommandOf?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const COMMAND_REGISTRY: {
|
|
17
|
+
readonly status: {
|
|
18
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
19
|
+
readonly description: "Show current swarm state";
|
|
20
|
+
};
|
|
21
|
+
readonly plan: {
|
|
22
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
23
|
+
readonly description: "Show plan (optionally filter by phase number)";
|
|
24
|
+
};
|
|
25
|
+
readonly agents: {
|
|
26
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
27
|
+
readonly description: "List registered agents";
|
|
28
|
+
};
|
|
29
|
+
readonly history: {
|
|
30
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
31
|
+
readonly description: "Show completed phases summary";
|
|
32
|
+
};
|
|
33
|
+
readonly config: {
|
|
34
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
35
|
+
readonly description: "Show current resolved configuration";
|
|
36
|
+
};
|
|
37
|
+
readonly 'config doctor': {
|
|
38
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
39
|
+
readonly description: "Run config doctor checks";
|
|
40
|
+
readonly subcommandOf: "config";
|
|
41
|
+
};
|
|
42
|
+
readonly diagnose: {
|
|
43
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
44
|
+
readonly description: "Run health check on swarm state";
|
|
45
|
+
};
|
|
46
|
+
readonly preflight: {
|
|
47
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
48
|
+
readonly description: "Run preflight automation checks";
|
|
49
|
+
};
|
|
50
|
+
readonly 'sync-plan': {
|
|
51
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
52
|
+
readonly description: "Ensure plan.json and plan.md are synced";
|
|
53
|
+
};
|
|
54
|
+
readonly benchmark: {
|
|
55
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
56
|
+
readonly description: "Show performance metrics [--cumulative] [--ci-gate]";
|
|
57
|
+
};
|
|
58
|
+
readonly export: {
|
|
59
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
60
|
+
readonly description: "Export plan and context as JSON";
|
|
61
|
+
};
|
|
62
|
+
readonly evidence: {
|
|
63
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
64
|
+
readonly description: "Show evidence bundles [taskId]";
|
|
65
|
+
};
|
|
66
|
+
readonly 'evidence summary': {
|
|
67
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
68
|
+
readonly description: "Generate evidence summary with completion ratio and blockers";
|
|
69
|
+
readonly subcommandOf: "evidence";
|
|
70
|
+
};
|
|
71
|
+
readonly archive: {
|
|
72
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
73
|
+
readonly description: "Archive old evidence bundles [--dry-run]";
|
|
74
|
+
};
|
|
75
|
+
readonly curate: {
|
|
76
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
77
|
+
readonly description: "Run knowledge curation and hive promotion review";
|
|
78
|
+
};
|
|
79
|
+
readonly 'dark-matter': {
|
|
80
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
81
|
+
readonly description: "Detect hidden file couplings via co-change NPMI analysis";
|
|
82
|
+
};
|
|
83
|
+
readonly simulate: {
|
|
84
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
85
|
+
readonly description: "Dry-run impact analysis of proposed changes [--target <glob>]";
|
|
86
|
+
};
|
|
87
|
+
readonly analyze: {
|
|
88
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
89
|
+
readonly description: "Analyze spec.md vs plan.md for requirement coverage gaps";
|
|
90
|
+
};
|
|
91
|
+
readonly clarify: {
|
|
92
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
93
|
+
readonly description: "Clarify and refine an existing feature specification";
|
|
94
|
+
};
|
|
95
|
+
readonly specify: {
|
|
96
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
97
|
+
readonly description: "Generate or import a feature specification [description]";
|
|
98
|
+
};
|
|
99
|
+
readonly promote: {
|
|
100
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
101
|
+
readonly description: "Manually promote lesson to hive knowledge";
|
|
102
|
+
};
|
|
103
|
+
readonly reset: {
|
|
104
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
105
|
+
readonly description: "Clear swarm state files [--confirm]";
|
|
106
|
+
};
|
|
107
|
+
readonly rollback: {
|
|
108
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
109
|
+
readonly description: "Restore swarm state to a checkpoint <phase>";
|
|
110
|
+
};
|
|
111
|
+
readonly retrieve: {
|
|
112
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
113
|
+
readonly description: "Retrieve full output from a summary <id>";
|
|
114
|
+
};
|
|
115
|
+
readonly handoff: {
|
|
116
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
117
|
+
readonly description: "Prepare state for clean model switch (new session)";
|
|
118
|
+
};
|
|
119
|
+
readonly turbo: {
|
|
120
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
121
|
+
readonly description: "Toggle Turbo Mode for the active session [on|off]";
|
|
122
|
+
};
|
|
123
|
+
readonly 'write-retro': {
|
|
124
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
125
|
+
readonly description: "Write a retrospective evidence bundle for a completed phase <json>";
|
|
126
|
+
};
|
|
127
|
+
readonly 'knowledge migrate': {
|
|
128
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
129
|
+
readonly description: "Migrate knowledge entries to the current format";
|
|
130
|
+
readonly subcommandOf: "knowledge";
|
|
131
|
+
};
|
|
132
|
+
readonly 'knowledge quarantine': {
|
|
133
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
134
|
+
readonly description: "Move a knowledge entry to quarantine <id> [reason]";
|
|
135
|
+
readonly subcommandOf: "knowledge";
|
|
136
|
+
};
|
|
137
|
+
readonly 'knowledge restore': {
|
|
138
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
139
|
+
readonly description: "Restore a quarantined knowledge entry <id>";
|
|
140
|
+
readonly subcommandOf: "knowledge";
|
|
141
|
+
};
|
|
142
|
+
readonly knowledge: {
|
|
143
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
144
|
+
readonly description: "List knowledge entries";
|
|
145
|
+
};
|
|
146
|
+
readonly checkpoint: {
|
|
147
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
148
|
+
readonly description: "Manage project checkpoints [save|restore|delete|list] <label>";
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
export type RegisteredCommand = keyof typeof COMMAND_REGISTRY;
|
|
152
|
+
export declare const VALID_COMMANDS: RegisteredCommand[];
|
|
153
|
+
/**
|
|
154
|
+
* Resolves compound commands like "evidence summary" and "config doctor".
|
|
155
|
+
* Tries a two-token compound key first, then falls back to a single-token key.
|
|
156
|
+
*/
|
|
157
|
+
export declare function resolveCommand(tokens: string[]): {
|
|
158
|
+
entry: CommandEntry;
|
|
159
|
+
remainingArgs: string[];
|
|
160
|
+
} | null;
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -324,6 +324,17 @@ export declare const GuardrailsConfigSchema: z.ZodObject<{
|
|
|
324
324
|
}, z.core.$strip>>>;
|
|
325
325
|
}, z.core.$strip>;
|
|
326
326
|
export type GuardrailsConfig = z.infer<typeof GuardrailsConfigSchema>;
|
|
327
|
+
export declare const WatchdogConfigSchema: z.ZodObject<{
|
|
328
|
+
scope_guard: z.ZodDefault<z.ZodBoolean>;
|
|
329
|
+
skip_in_turbo: z.ZodDefault<z.ZodBoolean>;
|
|
330
|
+
delegation_ledger: z.ZodDefault<z.ZodBoolean>;
|
|
331
|
+
}, z.core.$strip>;
|
|
332
|
+
export type WatchdogConfig = z.infer<typeof WatchdogConfigSchema>;
|
|
333
|
+
export declare const SelfReviewConfigSchema: z.ZodObject<{
|
|
334
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
335
|
+
skip_in_turbo: z.ZodDefault<z.ZodBoolean>;
|
|
336
|
+
}, z.core.$strip>;
|
|
337
|
+
export type SelfReviewConfig = z.infer<typeof SelfReviewConfigSchema>;
|
|
327
338
|
/**
|
|
328
339
|
* Resolves guardrails configuration for a specific agent.
|
|
329
340
|
*
|
|
@@ -430,6 +441,7 @@ export declare const SlopDetectorConfigSchema: z.ZodObject<{
|
|
|
430
441
|
classThreshold: z.ZodDefault<z.ZodNumber>;
|
|
431
442
|
commentStripThreshold: z.ZodDefault<z.ZodNumber>;
|
|
432
443
|
diffLineThreshold: z.ZodDefault<z.ZodNumber>;
|
|
444
|
+
importHygieneThreshold: z.ZodDefault<z.ZodNumber>;
|
|
433
445
|
}, z.core.$strip>;
|
|
434
446
|
export type SlopDetectorConfig = z.infer<typeof SlopDetectorConfigSchema>;
|
|
435
447
|
export declare const IncrementalVerifyConfigSchema: z.ZodObject<{
|
|
@@ -580,6 +592,15 @@ export declare const PluginConfigSchema: z.ZodObject<{
|
|
|
580
592
|
idle_timeout_minutes: z.ZodOptional<z.ZodNumber>;
|
|
581
593
|
}, z.core.$strip>>>;
|
|
582
594
|
}, z.core.$strip>>;
|
|
595
|
+
watchdog: z.ZodOptional<z.ZodObject<{
|
|
596
|
+
scope_guard: z.ZodDefault<z.ZodBoolean>;
|
|
597
|
+
skip_in_turbo: z.ZodDefault<z.ZodBoolean>;
|
|
598
|
+
delegation_ledger: z.ZodDefault<z.ZodBoolean>;
|
|
599
|
+
}, z.core.$strip>>;
|
|
600
|
+
self_review: z.ZodOptional<z.ZodObject<{
|
|
601
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
602
|
+
skip_in_turbo: z.ZodDefault<z.ZodBoolean>;
|
|
603
|
+
}, z.core.$strip>>;
|
|
583
604
|
tool_filter: z.ZodOptional<z.ZodObject<{
|
|
584
605
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
585
606
|
overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
@@ -722,6 +743,7 @@ export declare const PluginConfigSchema: z.ZodObject<{
|
|
|
722
743
|
classThreshold: z.ZodDefault<z.ZodNumber>;
|
|
723
744
|
commentStripThreshold: z.ZodDefault<z.ZodNumber>;
|
|
724
745
|
diffLineThreshold: z.ZodDefault<z.ZodNumber>;
|
|
746
|
+
importHygieneThreshold: z.ZodDefault<z.ZodNumber>;
|
|
725
747
|
}, z.core.$strip>>;
|
|
726
748
|
incremental_verify: z.ZodOptional<z.ZodObject<{
|
|
727
749
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -19,7 +19,7 @@ export declare function writeDriftReport(directory: string, report: DriftReport)
|
|
|
19
19
|
* On any error: emits 'curator.error' event and returns a safe default result.
|
|
20
20
|
* NEVER throws — drift failures must not block phase_complete.
|
|
21
21
|
*/
|
|
22
|
-
export declare function runCriticDriftCheck(directory: string, phase: number, curatorResult: CuratorPhaseResult, config: CuratorConfig): Promise<CriticDriftResult>;
|
|
22
|
+
export declare function runCriticDriftCheck(directory: string, phase: number, curatorResult: CuratorPhaseResult, config: CuratorConfig, injectAdvisory?: (message: string) => void): Promise<CriticDriftResult>;
|
|
23
23
|
/**
|
|
24
24
|
* Build a truncated summary suitable for architect context injection.
|
|
25
25
|
* Format: "<drift_report>Phase N: {alignment} ({drift_score}) — {key finding}. {correction if any}.</drift_report>"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DELEGATION LEDGER (v6.31 Task 3.2)
|
|
3
|
+
*
|
|
4
|
+
* tool.execute.after hook that maintains a per-session in-memory ledger of tool calls
|
|
5
|
+
* made during a delegation. When the architect session receives a message (resume),
|
|
6
|
+
* injects a compact DELEGATION SUMMARY via pendingAdvisoryMessages.
|
|
7
|
+
*
|
|
8
|
+
* No file I/O — fully in-memory.
|
|
9
|
+
*/
|
|
10
|
+
export interface LedgerEntry {
|
|
11
|
+
agent: string;
|
|
12
|
+
tool: string;
|
|
13
|
+
file?: string;
|
|
14
|
+
duration_ms: number;
|
|
15
|
+
success: boolean;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}
|
|
18
|
+
export interface DelegationLedgerConfig {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates the delegation ledger hook pair (toolAfter + summary injection).
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDelegationLedgerHook(config: Partial<DelegationLedgerConfig>, _directory: string, // reserved for future use
|
|
25
|
+
injectAdvisory: (sessionId: string, message: string) => void): {
|
|
26
|
+
toolAfter: (input: {
|
|
27
|
+
tool: string;
|
|
28
|
+
sessionID: string;
|
|
29
|
+
callID: string;
|
|
30
|
+
args?: Record<string, unknown>;
|
|
31
|
+
}, output: {
|
|
32
|
+
title: string;
|
|
33
|
+
output: string;
|
|
34
|
+
metadata: unknown;
|
|
35
|
+
}) => Promise<void>;
|
|
36
|
+
onArchitectResume: (sessionId: string) => void;
|
|
37
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegation-ledger.test.ts
|
|
3
|
+
*
|
|
4
|
+
* Tests for delegation-ledger hook (Task 3.2):
|
|
5
|
+
* 1. toolAfter records entries in ledgerBySession
|
|
6
|
+
* 2. onArchitectResume generates DELEGATION SUMMARY when non-architect tool calls exist
|
|
7
|
+
* 3. onArchitectResume is no-op when no entries exist
|
|
8
|
+
* 4. Success is false when output starts with 'Error:'
|
|
9
|
+
* 5. Success is true for normal output
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smoke test: documents the confirmed behavior that tool.execute.before hook
|
|
3
|
+
* throws propagate as tool rejection, not session crash.
|
|
4
|
+
*
|
|
5
|
+
* VERIFIED from src/hooks/guardrails.ts existing patterns:
|
|
6
|
+
* - Loop circuit breaker (count >= 5): throw new Error('CIRCUIT BREAKER...')
|
|
7
|
+
* - Full test suite block: throw new Error('BLOCKED: Full test suite...')
|
|
8
|
+
* - Plan state violation: throw new Error('PLAN STATE VIOLATION...')
|
|
9
|
+
* All throw in toolBefore, and the plugin propagates as tool rejection.
|
|
10
|
+
*
|
|
11
|
+
* SAFE MECHANISM for scope-guard.ts:
|
|
12
|
+
* throw new Error(`SCOPE VIOLATION: [agent] attempted to modify [file] not in task [id] scope`)
|
|
13
|
+
* This is the CORRECT blocking pattern. DO NOT use return-value signals.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCOPE GUARD (v6.31 Task 3.1)
|
|
3
|
+
*
|
|
4
|
+
* CONFIRMED THROW MECHANISM: throwing in tool.execute.before propagates as tool rejection,
|
|
5
|
+
* NOT as session crash. Verified from guardrails.ts multiple existing throw sites.
|
|
6
|
+
* Safe blocking pattern: throw new Error(`SCOPE VIOLATION: ...`)
|
|
7
|
+
*
|
|
8
|
+
* Fires BEFORE write/edit tools execute. When a non-architect agent attempts to
|
|
9
|
+
* modify a file outside the declared task scope, blocks the call and injects an advisory.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for scope guard behavior.
|
|
13
|
+
*/
|
|
14
|
+
export interface ScopeGuardConfig {
|
|
15
|
+
/** Whether scope guard is enabled (default: true) */
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
/** Whether to skip in turbo mode (default: false — NOT skippable by design) */
|
|
18
|
+
skip_in_turbo: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates the scope-guard hook that blocks out-of-scope writes.
|
|
22
|
+
* @param config - ScopeGuardConfig (enabled, skip_in_turbo)
|
|
23
|
+
* @param _directory - The workspace directory (reserved for future use)
|
|
24
|
+
* @param injectAdvisory - Optional callback to push advisory to architect session
|
|
25
|
+
*/
|
|
26
|
+
export declare function createScopeGuardHook(config: Partial<ScopeGuardConfig>, _directory: string, injectAdvisory?: (sessionId: string, message: string) => void): {
|
|
27
|
+
toolBefore: (input: {
|
|
28
|
+
tool: string;
|
|
29
|
+
sessionID: string;
|
|
30
|
+
callID: string;
|
|
31
|
+
}, output: {
|
|
32
|
+
args: unknown;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Check if a file path is within declared scope entries.
|
|
37
|
+
* Handles exact match and directory containment.
|
|
38
|
+
*
|
|
39
|
+
* @param filePath - The file path to check
|
|
40
|
+
* @param scopeEntries - Array of declared scope entries (files or directories)
|
|
41
|
+
* @returns true if the file is within scope, false otherwise
|
|
42
|
+
*/
|
|
43
|
+
export declare function isFileInScope(filePath: string, scopeEntries: string[]): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* scope-guard.test.ts
|
|
3
|
+
*
|
|
4
|
+
* Tests for scope-guard hook (Task 3.1):
|
|
5
|
+
* 1. Returns early (no throw) when guard is disabled (config.enabled = false)
|
|
6
|
+
* 2. Returns early when tool is not in WRITE_TOOLS set (e.g., 'read')
|
|
7
|
+
* 3. Returns early when session is the architect (agentName = 'Architect')
|
|
8
|
+
* 4. Returns early when declaredCoderScope is null (no scope declared)
|
|
9
|
+
* 5. Throws 'SCOPE VIOLATION' when non-architect writes file outside declared scope
|
|
10
|
+
* 6. Does NOT throw when non-architect writes file INSIDE declared scope
|
|
11
|
+
* 7. Sanitizes path with \r\n to prevent log injection (SEC-1 fix)
|
|
12
|
+
* 8. isFileInScope correctly handles exact match and directory containment
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SelfReviewConfig {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
skip_in_turbo: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function createSelfReviewHook(config: Partial<SelfReviewConfig>, injectAdvisory: (sessionId: string, message: string) => void): {
|
|
6
|
+
toolAfter: (input: {
|
|
7
|
+
tool: string;
|
|
8
|
+
sessionID: string;
|
|
9
|
+
callID: string;
|
|
10
|
+
}, output: {
|
|
11
|
+
args?: Record<string, unknown>;
|
|
12
|
+
output?: unknown;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* self-review.test.ts
|
|
3
|
+
*
|
|
4
|
+
* Tests for self-review hook (Task 4.1):
|
|
5
|
+
* 1. Advisory injected when architect calls update_task_status with status=in_progress
|
|
6
|
+
* 2. NOT injected when status=completed (not in_progress)
|
|
7
|
+
* 3. NOT injected when calling session is not architect
|
|
8
|
+
* 4. Turbo-skip: NOT injected when session.turboMode=true and skip_in_turbo=true
|
|
9
|
+
* 5. Disabled: NOT injected when enabled=false
|
|
10
|
+
* 6. Advisory text contains self-review focus items
|
|
11
|
+
* 7. injectAdvisory errors are caught (non-blocking)
|
|
12
|
+
* 8. No advisory for other tools (not update_task_status)
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WATCHDOG INTEGRATION TEST (v6.31 Task 3.5)
|
|
3
|
+
*
|
|
4
|
+
* Integration test covering coordinated watchdog behaviour across:
|
|
5
|
+
* - scope-guard (3.1): toolBefore hook blocks out-of-scope writes by throwing
|
|
6
|
+
* - delegation-ledger (3.2): toolAfter hook records tool calls, onArchitectResume generates DELEGATION SUMMARY
|
|
7
|
+
* - loop-detector enhancement (3.3): at count=3, structured escalation message includes loop pattern + accomplishment + alternative suggestion
|
|
8
|
+
*/
|
|
9
|
+
export {};
|