thoth-plugin 1.1.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.
Files changed (89) hide show
  1. package/README.md +84 -0
  2. package/dist/agents/archivist.d.ts +2 -0
  3. package/dist/agents/chronicler.d.ts +2 -0
  4. package/dist/agents/coach.d.ts +2 -0
  5. package/dist/agents/code-master.d.ts +2 -0
  6. package/dist/agents/diplomat.d.ts +2 -0
  7. package/dist/agents/index.d.ts +12 -0
  8. package/dist/agents/life-master.d.ts +2 -0
  9. package/dist/agents/scribe.d.ts +2 -0
  10. package/dist/agents/sentinel.d.ts +2 -0
  11. package/dist/agents/thoth.d.ts +37 -0
  12. package/dist/agents/work-master.d.ts +2 -0
  13. package/dist/cli.d.ts +9 -0
  14. package/dist/cli.js +220 -0
  15. package/dist/config/index.d.ts +1 -0
  16. package/dist/config/schema.d.ts +99 -0
  17. package/dist/defaults/AGENTS.md +53 -0
  18. package/dist/defaults/skill/cal-grid/SKILL.md +16 -0
  19. package/dist/defaults/skill/capsule-init/SKILL.md +102 -0
  20. package/dist/defaults/skill/cross-linker/SKILL.md +357 -0
  21. package/dist/defaults/skill/evening-close/SKILL.md +91 -0
  22. package/dist/defaults/skill/gardener/SKILL.md +248 -0
  23. package/dist/defaults/skill/gardener/confidence-tiers.md +142 -0
  24. package/dist/defaults/skill/gardener/repair-workflow.md +170 -0
  25. package/dist/defaults/skill/google-chat-scan/SKILL.md +135 -0
  26. package/dist/defaults/skill/handover/SKILL.md +18 -0
  27. package/dist/defaults/skill/interview-prep/SKILL.md +23 -0
  28. package/dist/defaults/skill/leadership-coach/SKILL.md +160 -0
  29. package/dist/defaults/skill/link-retrofit/SKILL.md +345 -0
  30. package/dist/defaults/skill/mail-triage/SKILL.md +16 -0
  31. package/dist/defaults/skill/morning-boot/SKILL.md +98 -0
  32. package/dist/defaults/skill/post-meeting-drill/SKILL.md +479 -0
  33. package/dist/defaults/skill/restore-environment/SKILL.md +30 -0
  34. package/dist/defaults/skill/scorecard-synthesis/SKILL.md +26 -0
  35. package/dist/defaults/skill/skill-generator/SKILL.md +240 -0
  36. package/dist/defaults/skill/skill-generator/testing-protocol.md +158 -0
  37. package/dist/defaults/skill/slack-pulse/SKILL.md +16 -0
  38. package/dist/defaults/skill/system-init/SKILL.md +103 -0
  39. package/dist/defaults/skill/thought-router/SKILL.md +80 -0
  40. package/dist/hooks/context-aperture.d.ts +37 -0
  41. package/dist/hooks/context-aperture.test.d.ts +1 -0
  42. package/dist/hooks/directory-agents-injector/constants.d.ts +6 -0
  43. package/dist/hooks/directory-agents-injector/index.d.ts +21 -0
  44. package/dist/hooks/directory-agents-injector/storage.d.ts +8 -0
  45. package/dist/hooks/directory-agents-injector/types.d.ts +24 -0
  46. package/dist/hooks/index.d.ts +4 -0
  47. package/dist/hooks/permission-enforcer.d.ts +15 -0
  48. package/dist/hooks/permission-enforcer.test.d.ts +1 -0
  49. package/dist/hooks/temporal-awareness.d.ts +31 -0
  50. package/dist/hooks/temporal-awareness.test.d.ts +1 -0
  51. package/dist/hooks/trust-level-tracker.d.ts +58 -0
  52. package/dist/hooks/trust-level-tracker.test.d.ts +1 -0
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.js +31196 -0
  55. package/dist/shared/index.d.ts +21 -0
  56. package/dist/shared-hooks/background-agent/index.d.ts +2 -0
  57. package/dist/shared-hooks/background-agent/manager.d.ts +39 -0
  58. package/dist/shared-hooks/background-agent/types.d.ts +30 -0
  59. package/dist/shared-hooks/background-notification/index.d.ts +12 -0
  60. package/dist/shared-hooks/background-notification/types.d.ts +4 -0
  61. package/dist/shared-hooks/context-window-monitor.d.ts +18 -0
  62. package/dist/shared-hooks/index.d.ts +7 -0
  63. package/dist/shared-hooks/session-recovery/constants.d.ts +6 -0
  64. package/dist/shared-hooks/session-recovery/index.d.ts +21 -0
  65. package/dist/shared-hooks/session-recovery/storage.d.ts +19 -0
  66. package/dist/shared-hooks/session-recovery/types.d.ts +90 -0
  67. package/dist/shared-hooks/todo-continuation-enforcer.d.ts +12 -0
  68. package/dist/shared-hooks/utils/constants.d.ts +6 -0
  69. package/dist/shared-hooks/utils/index.d.ts +5 -0
  70. package/dist/shared-hooks/utils/logger.d.ts +2 -0
  71. package/dist/shared-hooks/utils/message-storage.d.ts +6 -0
  72. package/dist/shared-hooks/utils/session-state.d.ts +4 -0
  73. package/dist/shared-hooks/utils/types.d.ts +141 -0
  74. package/dist/specialization/boot-sequences.d.ts +19 -0
  75. package/dist/specialization/detector.d.ts +20 -0
  76. package/dist/specialization/index.d.ts +10 -0
  77. package/dist/specialization/prompt-builder.d.ts +30 -0
  78. package/dist/specialization/prompt-sections.d.ts +19 -0
  79. package/dist/specialization/types.d.ts +86 -0
  80. package/dist/thoth-plugin.schema.json +7 -0
  81. package/dist/tools/background-task/constants.d.ts +3 -0
  82. package/dist/tools/background-task/index.d.ts +2 -0
  83. package/dist/tools/background-task/tools.d.ts +7 -0
  84. package/dist/tools/background-task/types.d.ts +14 -0
  85. package/dist/tools/index.d.ts +2 -0
  86. package/dist/tools/skill/index.d.ts +2 -0
  87. package/dist/tools/skill/tools.d.ts +2 -0
  88. package/dist/tools/skill/types.d.ts +37 -0
  89. package/package.json +54 -0
@@ -0,0 +1,21 @@
1
+ export declare function log(message: string, ...args: unknown[]): void;
2
+ export declare function expandPath(inputPath: string): string;
3
+ export declare function getUserConfigDir(): string;
4
+ export declare function fileExists(filePath: string): boolean;
5
+ export declare function readFileSync(filePath: string): string | null;
6
+ export declare function writeFileSync(filePath: string, content: string): boolean;
7
+ export declare function deepMerge<T extends Record<string, unknown>>(base: T, override: Partial<T> | undefined): T;
8
+ export declare function getTemporalContext(): TemporalContext;
9
+ export type DayMode = "launch" | "execution" | "closure" | "weekend-sanctuary";
10
+ export type BiologicalMode = "high-cognitive" | "collaborative" | "restoration" | "transition";
11
+ export interface TemporalContext {
12
+ date: string;
13
+ time: string;
14
+ dayOfWeek: string;
15
+ weekNumber: number;
16
+ quarter: number;
17
+ dayMode: DayMode;
18
+ biologicalMode: BiologicalMode;
19
+ isWeekend: boolean;
20
+ }
21
+ export declare function formatTemporalContext(ctx: TemporalContext): string;
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export { BackgroundManager } from "./manager";
@@ -0,0 +1,39 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ import type { BackgroundTask, LaunchInput } from "./types";
3
+ interface EventProperties {
4
+ sessionID?: string;
5
+ info?: {
6
+ id?: string;
7
+ };
8
+ [key: string]: unknown;
9
+ }
10
+ interface Event {
11
+ type: string;
12
+ properties?: EventProperties;
13
+ }
14
+ export declare class BackgroundManager {
15
+ private tasks;
16
+ private notifications;
17
+ private client;
18
+ private directory;
19
+ private pollingInterval?;
20
+ constructor(ctx: PluginInput);
21
+ launch(input: LaunchInput): Promise<BackgroundTask>;
22
+ getTask(id: string): BackgroundTask | undefined;
23
+ getTasksByParentSession(sessionID: string): BackgroundTask[];
24
+ getAllDescendantTasks(sessionID: string): BackgroundTask[];
25
+ findBySession(sessionID: string): BackgroundTask | undefined;
26
+ private checkSessionTodos;
27
+ handleEvent(event: Event): void;
28
+ markForNotification(task: BackgroundTask): void;
29
+ getPendingNotifications(sessionID: string): BackgroundTask[];
30
+ clearNotifications(sessionID: string): void;
31
+ private clearNotificationsForTask;
32
+ private startPolling;
33
+ private stopPolling;
34
+ private notifyParentSession;
35
+ private formatDuration;
36
+ private hasRunningTasks;
37
+ private pollRunningTasks;
38
+ }
39
+ export {};
@@ -0,0 +1,30 @@
1
+ export type BackgroundTaskStatus = "running" | "completed" | "error" | "cancelled";
2
+ export interface TaskProgress {
3
+ toolCalls: number;
4
+ lastTool?: string;
5
+ lastUpdate: Date;
6
+ lastMessage?: string;
7
+ lastMessageAt?: Date;
8
+ }
9
+ export interface BackgroundTask {
10
+ id: string;
11
+ sessionID: string;
12
+ parentSessionID: string;
13
+ parentMessageID: string;
14
+ description: string;
15
+ prompt: string;
16
+ agent: string;
17
+ status: BackgroundTaskStatus;
18
+ startedAt: Date;
19
+ completedAt?: Date;
20
+ result?: string;
21
+ error?: string;
22
+ progress?: TaskProgress;
23
+ }
24
+ export interface LaunchInput {
25
+ description: string;
26
+ prompt: string;
27
+ agent: string;
28
+ parentSessionID: string;
29
+ parentMessageID: string;
30
+ }
@@ -0,0 +1,12 @@
1
+ import type { BackgroundManager } from "../background-agent";
2
+ interface Event {
3
+ type: string;
4
+ properties?: Record<string, unknown>;
5
+ }
6
+ interface EventInput {
7
+ event: Event;
8
+ }
9
+ export declare function createBackgroundNotificationHook(manager: BackgroundManager): {
10
+ event: ({ event }: EventInput) => Promise<void>;
11
+ };
12
+ export type { BackgroundNotificationHookConfig } from "./types";
@@ -0,0 +1,4 @@
1
+ import type { BackgroundTask } from "../background-agent";
2
+ export interface BackgroundNotificationHookConfig {
3
+ formatNotification?: (tasks: BackgroundTask[]) => string;
4
+ }
@@ -0,0 +1,18 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export declare function createContextWindowMonitorHook(ctx: PluginInput): {
3
+ "tool.execute.after": (input: {
4
+ tool: string;
5
+ sessionID: string;
6
+ callID: string;
7
+ }, output: {
8
+ title: string;
9
+ output: string;
10
+ metadata: unknown;
11
+ }) => Promise<void>;
12
+ event: ({ event }: {
13
+ event: {
14
+ type: string;
15
+ properties?: unknown;
16
+ };
17
+ }) => Promise<void>;
18
+ };
@@ -0,0 +1,7 @@
1
+ export { createTodoContinuationEnforcer, type TodoContinuationEnforcer } from "./todo-continuation-enforcer";
2
+ export { createSessionRecoveryHook, type SessionRecoveryHook, type SessionRecoveryOptions } from "./session-recovery";
3
+ export { createContextWindowMonitorHook } from "./context-window-monitor";
4
+ export { BackgroundManager } from "./background-agent";
5
+ export { createBackgroundNotificationHook } from "./background-notification";
6
+ export { log, getLogFilePath } from "./utils/logger";
7
+ export { setMainSession, getMainSessionID, subagentSessions } from "./utils/session-state";
@@ -0,0 +1,6 @@
1
+ export declare const OPENCODE_STORAGE: string;
2
+ export declare const MESSAGE_STORAGE: string;
3
+ export declare const PART_STORAGE: string;
4
+ export declare const THINKING_TYPES: Set<string>;
5
+ export declare const META_TYPES: Set<string>;
6
+ export declare const CONTENT_TYPES: Set<string>;
@@ -0,0 +1,21 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export interface SessionRecoveryOptions {
3
+ experimental?: {
4
+ auto_resume?: boolean;
5
+ };
6
+ }
7
+ interface MessageInfo {
8
+ id?: string;
9
+ role?: string;
10
+ sessionID?: string;
11
+ parentID?: string;
12
+ error?: unknown;
13
+ }
14
+ export interface SessionRecoveryHook {
15
+ handleSessionRecovery: (info: MessageInfo) => Promise<boolean>;
16
+ isRecoverableError: (error: unknown) => boolean;
17
+ setOnAbortCallback: (callback: (sessionID: string) => void) => void;
18
+ setOnRecoveryCompleteCallback: (callback: (sessionID: string) => void) => void;
19
+ }
20
+ export declare function createSessionRecoveryHook(ctx: PluginInput, options?: SessionRecoveryOptions): SessionRecoveryHook;
21
+ export type { MessageData, ResumeConfig } from "./types";
@@ -0,0 +1,19 @@
1
+ import type { StoredMessageMeta, StoredPart } from "./types";
2
+ export declare function generatePartId(): string;
3
+ export declare function getMessageDir(sessionID: string): string;
4
+ export declare function readMessages(sessionID: string): StoredMessageMeta[];
5
+ export declare function readParts(messageID: string): StoredPart[];
6
+ export declare function hasContent(part: StoredPart): boolean;
7
+ export declare function messageHasContent(messageID: string): boolean;
8
+ export declare function injectTextPart(sessionID: string, messageID: string, text: string): boolean;
9
+ export declare function findEmptyMessages(sessionID: string): string[];
10
+ export declare function findEmptyMessageByIndex(sessionID: string, targetIndex: number): string | null;
11
+ export declare function findFirstEmptyMessage(sessionID: string): string | null;
12
+ export declare function findMessagesWithThinkingBlocks(sessionID: string): string[];
13
+ export declare function findMessagesWithThinkingOnly(sessionID: string): string[];
14
+ export declare function findMessagesWithOrphanThinking(sessionID: string): string[];
15
+ export declare function prependThinkingPart(sessionID: string, messageID: string): boolean;
16
+ export declare function stripThinkingParts(messageID: string): boolean;
17
+ export declare function replaceEmptyTextParts(messageID: string, replacementText: string): boolean;
18
+ export declare function findMessagesWithEmptyTextParts(sessionID: string): string[];
19
+ export declare function findMessageByIndexNeedingThinking(sessionID: string, targetIndex: number): string | null;
@@ -0,0 +1,90 @@
1
+ export type ThinkingPartType = "thinking" | "redacted_thinking" | "reasoning";
2
+ export type MetaPartType = "step-start" | "step-finish";
3
+ export type ContentPartType = "text" | "tool" | "tool_use" | "tool_result";
4
+ export interface StoredMessageMeta {
5
+ id: string;
6
+ sessionID: string;
7
+ role: "user" | "assistant";
8
+ parentID?: string;
9
+ time?: {
10
+ created: number;
11
+ completed?: number;
12
+ };
13
+ error?: unknown;
14
+ }
15
+ export interface StoredTextPart {
16
+ id: string;
17
+ sessionID: string;
18
+ messageID: string;
19
+ type: "text";
20
+ text: string;
21
+ synthetic?: boolean;
22
+ ignored?: boolean;
23
+ }
24
+ export interface StoredToolPart {
25
+ id: string;
26
+ sessionID: string;
27
+ messageID: string;
28
+ type: "tool";
29
+ callID: string;
30
+ tool: string;
31
+ state: {
32
+ status: "pending" | "running" | "completed" | "error";
33
+ input: Record<string, unknown>;
34
+ output?: string;
35
+ error?: string;
36
+ };
37
+ }
38
+ export interface StoredReasoningPart {
39
+ id: string;
40
+ sessionID: string;
41
+ messageID: string;
42
+ type: "reasoning";
43
+ text: string;
44
+ }
45
+ export interface StoredStepPart {
46
+ id: string;
47
+ sessionID: string;
48
+ messageID: string;
49
+ type: "step-start" | "step-finish";
50
+ }
51
+ export type StoredPart = StoredTextPart | StoredToolPart | StoredReasoningPart | StoredStepPart | {
52
+ id: string;
53
+ sessionID: string;
54
+ messageID: string;
55
+ type: string;
56
+ [key: string]: unknown;
57
+ };
58
+ export interface MessageData {
59
+ info?: {
60
+ id?: string;
61
+ role?: string;
62
+ sessionID?: string;
63
+ parentID?: string;
64
+ error?: unknown;
65
+ agent?: string;
66
+ model?: {
67
+ providerID: string;
68
+ modelID: string;
69
+ };
70
+ system?: string;
71
+ tools?: Record<string, boolean>;
72
+ };
73
+ parts?: Array<{
74
+ type: string;
75
+ id?: string;
76
+ text?: string;
77
+ thinking?: string;
78
+ name?: string;
79
+ input?: Record<string, unknown>;
80
+ callID?: string;
81
+ }>;
82
+ }
83
+ export interface ResumeConfig {
84
+ sessionID: string;
85
+ agent?: string;
86
+ model?: {
87
+ providerID: string;
88
+ modelID: string;
89
+ };
90
+ }
@@ -0,0 +1,12 @@
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
+ export interface TodoContinuationEnforcer {
3
+ handler: (input: {
4
+ event: {
5
+ type: string;
6
+ properties?: unknown;
7
+ };
8
+ }) => Promise<void>;
9
+ markRecovering: (sessionID: string) => void;
10
+ markRecoveryComplete: (sessionID: string) => void;
11
+ }
12
+ export declare function createTodoContinuationEnforcer(ctx: PluginInput): TodoContinuationEnforcer;
@@ -0,0 +1,6 @@
1
+ export declare const OPENCODE_STORAGE: string;
2
+ export declare const MESSAGE_STORAGE: string;
3
+ export declare const PART_STORAGE: string;
4
+ export declare const THINKING_TYPES: Set<string>;
5
+ export declare const META_TYPES: Set<string>;
6
+ export declare const CONTENT_TYPES: Set<string>;
@@ -0,0 +1,5 @@
1
+ export { log, getLogFilePath } from "./logger";
2
+ export { OPENCODE_STORAGE, MESSAGE_STORAGE, PART_STORAGE, THINKING_TYPES, META_TYPES, CONTENT_TYPES } from "./constants";
3
+ export * from "./types";
4
+ export { subagentSessions, mainSessionID, setMainSession, getMainSessionID } from "./session-state";
5
+ export { findNearestMessageWithFields, getMessageDir, injectHookMessage } from "./message-storage";
@@ -0,0 +1,2 @@
1
+ export declare function log(message: string, data?: unknown): void;
2
+ export declare function getLogFilePath(): string;
@@ -0,0 +1,6 @@
1
+ import { MESSAGE_STORAGE, PART_STORAGE } from "./constants";
2
+ import type { OriginalMessageContext, StoredMessage } from "./types";
3
+ export declare function findNearestMessageWithFields(messageDir: string): StoredMessage | null;
4
+ export declare function getMessageDir(sessionID: string): string | null;
5
+ export declare function injectHookMessage(sessionID: string, hookContent: string, originalMessage: OriginalMessageContext): boolean;
6
+ export { MESSAGE_STORAGE, PART_STORAGE };
@@ -0,0 +1,4 @@
1
+ export declare const subagentSessions: Set<string>;
2
+ export declare let mainSessionID: string | undefined;
3
+ export declare function setMainSession(id: string | undefined): void;
4
+ export declare function getMainSessionID(): string | undefined;
@@ -0,0 +1,141 @@
1
+ export interface MessageMeta {
2
+ id: string;
3
+ sessionID: string;
4
+ role: "user" | "assistant";
5
+ time: {
6
+ created: number;
7
+ completed?: number;
8
+ };
9
+ agent?: string;
10
+ model?: {
11
+ providerID: string;
12
+ modelID: string;
13
+ };
14
+ path?: {
15
+ cwd: string;
16
+ root: string;
17
+ };
18
+ tools?: Record<string, boolean>;
19
+ }
20
+ export interface OriginalMessageContext {
21
+ agent?: string;
22
+ model?: {
23
+ providerID?: string;
24
+ modelID?: string;
25
+ };
26
+ path?: {
27
+ cwd?: string;
28
+ root?: string;
29
+ };
30
+ tools?: Record<string, boolean>;
31
+ }
32
+ export interface TextPart {
33
+ id: string;
34
+ type: "text";
35
+ text: string;
36
+ synthetic: boolean;
37
+ time: {
38
+ start: number;
39
+ end: number;
40
+ };
41
+ messageID: string;
42
+ sessionID: string;
43
+ }
44
+ export type ThinkingPartType = "thinking" | "redacted_thinking" | "reasoning";
45
+ export type MetaPartType = "step-start" | "step-finish";
46
+ export type ContentPartType = "text" | "tool" | "tool_use" | "tool_result";
47
+ export interface StoredMessageMeta {
48
+ id: string;
49
+ sessionID: string;
50
+ role: "user" | "assistant";
51
+ parentID?: string;
52
+ time?: {
53
+ created: number;
54
+ completed?: number;
55
+ };
56
+ error?: unknown;
57
+ }
58
+ export interface StoredTextPart {
59
+ id: string;
60
+ sessionID: string;
61
+ messageID: string;
62
+ type: "text";
63
+ text: string;
64
+ synthetic?: boolean;
65
+ ignored?: boolean;
66
+ }
67
+ export interface StoredToolPart {
68
+ id: string;
69
+ sessionID: string;
70
+ messageID: string;
71
+ type: "tool";
72
+ callID: string;
73
+ tool: string;
74
+ state: {
75
+ status: "pending" | "running" | "completed" | "error";
76
+ input: Record<string, unknown>;
77
+ output?: string;
78
+ error?: string;
79
+ };
80
+ }
81
+ export interface StoredReasoningPart {
82
+ id: string;
83
+ sessionID: string;
84
+ messageID: string;
85
+ type: "reasoning";
86
+ text: string;
87
+ }
88
+ export interface StoredStepPart {
89
+ id: string;
90
+ sessionID: string;
91
+ messageID: string;
92
+ type: "step-start" | "step-finish";
93
+ }
94
+ export type StoredPart = StoredTextPart | StoredToolPart | StoredReasoningPart | StoredStepPart | {
95
+ id: string;
96
+ sessionID: string;
97
+ messageID: string;
98
+ type: string;
99
+ [key: string]: unknown;
100
+ };
101
+ export interface MessageData {
102
+ info?: {
103
+ id?: string;
104
+ role?: string;
105
+ sessionID?: string;
106
+ parentID?: string;
107
+ error?: unknown;
108
+ agent?: string;
109
+ model?: {
110
+ providerID: string;
111
+ modelID: string;
112
+ };
113
+ system?: string;
114
+ tools?: Record<string, boolean>;
115
+ };
116
+ parts?: Array<{
117
+ type: string;
118
+ id?: string;
119
+ text?: string;
120
+ thinking?: string;
121
+ name?: string;
122
+ input?: Record<string, unknown>;
123
+ callID?: string;
124
+ }>;
125
+ }
126
+ export interface ResumeConfig {
127
+ sessionID: string;
128
+ agent?: string;
129
+ model?: {
130
+ providerID: string;
131
+ modelID: string;
132
+ };
133
+ }
134
+ export interface StoredMessage {
135
+ agent?: string;
136
+ model?: {
137
+ providerID?: string;
138
+ modelID?: string;
139
+ };
140
+ tools?: Record<string, boolean>;
141
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Boot Sequences
3
+ *
4
+ * Defines what files should be loaded at each depth/domain combination.
5
+ */
6
+ import type { Domain, DepthLevel } from "./types";
7
+ /**
8
+ * Get the boot sequence for a given specialization
9
+ */
10
+ export declare function getBootSequence(depth: DepthLevel, domain: Domain | null, category: string | null, relativePath: string, overrideSequence?: string[]): string[];
11
+ /**
12
+ * Resolve boot sequence paths relative to current working directory
13
+ * Falls back to npm package defaults if file not found in knowledge base
14
+ */
15
+ export declare function resolveBootPaths(bootSequence: string[], cwd: string, knowledgeBasePath: string): string[];
16
+ /**
17
+ * Get a human-readable description of the boot sequence
18
+ */
19
+ export declare function describeBootSequence(bootSequence: string[]): string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Specialization Detector
3
+ *
4
+ * Detects the appropriate depth and domain based on the current working directory.
5
+ * Uses a hybrid approach: folder depth as default, with overrides via AGENTS.md or CONTEXT.md.
6
+ */
7
+ import type { Specialization, ParsedAgentsMd } from "./types";
8
+ /**
9
+ * Main detection function: determines specialization from current working directory
10
+ */
11
+ export declare function detectSpecialization(cwd: string, knowledgeBasePath: string): Specialization;
12
+ /**
13
+ * Find all AGENTS.md files from cwd up to knowledge base root
14
+ * Returns paths from root to deepest (for layered injection)
15
+ */
16
+ export declare function findAgentsMdChain(cwd: string, knowledgeBasePath: string): ParsedAgentsMd[];
17
+ /**
18
+ * Check if a path is within the knowledge base
19
+ */
20
+ export declare function isWithinKnowledgeBase(filePath: string, knowledgeBasePath: string): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Specialization Module
3
+ *
4
+ * Main exports for Thoth's depth-based specialization system.
5
+ */
6
+ export type { Domain, DepthLevel, Specialization, AgentsMdFrontmatter, ParsedAgentsMd, SessionSpecializationState, BootInstruction, } from "./types";
7
+ export { detectSpecialization, findAgentsMdChain, isWithinKnowledgeBase, } from "./detector";
8
+ export { getBootSequence, resolveBootPaths, describeBootSequence, } from "./boot-sequences";
9
+ export { THOTH_CORE_IDENTITY, HEMISPHERE_VOICE, CATEGORY_EXPERTISE, DEEP_EXPERTISE, getFocusInstruction, getModeConfirmationTemplate, } from "./prompt-sections";
10
+ export { buildThothPrompt, buildThothPromptWithBoot, getBootInstruction, readBootContent, } from "./prompt-builder";
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Prompt Builder
3
+ *
4
+ * Assembles the final Thoth system prompt based on specialization.
5
+ * Uses additive depth inheritance: each level adds to the previous.
6
+ */
7
+ import type { Specialization } from "./types";
8
+ /**
9
+ * Build the complete Thoth system prompt based on specialization.
10
+ *
11
+ * Uses ADDITIVE depth inheritance:
12
+ * - Depth 0: Core only
13
+ * - Depth 1: Core + Hemisphere Voice
14
+ * - Depth 2: Core + Hemisphere Voice + Category Expertise
15
+ * - Depth 3: Core + Hemisphere Voice + Category Expertise + Deep Expertise
16
+ */
17
+ export declare function buildThothPrompt(spec: Specialization): string;
18
+ /**
19
+ * Get the boot instruction to inject on first message
20
+ */
21
+ export declare function getBootInstruction(spec: Specialization): string;
22
+ /**
23
+ * Read boot files and return their content for injection into the prompt.
24
+ * This pre-loads context so Thoth doesn't have to read files on first message.
25
+ */
26
+ export declare function readBootContent(spec: Specialization, cwd: string, knowledgeBasePath: string): string | null;
27
+ /**
28
+ * Build prompt with boot content included
29
+ */
30
+ export declare function buildThothPromptWithBoot(spec: Specialization, cwd: string, knowledgeBasePath: string): string;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Prompt Sections
3
+ *
4
+ * Defines the voice modifiers and expertise sections for each depth/domain.
5
+ * These are assembled by the prompt builder into the final system prompt.
6
+ *
7
+ * IMPORTANT: Voice changes MUST be in the system prompt to be reliable.
8
+ * AGENTS.md provides contextual reinforcement, but voice is defined here.
9
+ */
10
+ import type { Domain, DepthLevel, Specialization } from "./types";
11
+ export declare const THOTH_CORE_IDENTITY = "<Identity>\nYou are **Thoth** \u2014 Zeus's root-level life orchestrator and trusted chief of staff.\n\nNamed after the Egyptian scribe-god who recorded the weighing of hearts \u2014 you observe, record, and judge fairly. You are executor and archivist: integrate every significant detail into the knowledge base. Build the knowledge graph. Link concepts. Ensure nothing important is lost.\n\n**Your relationship with Zeus**: Proactive executive partner. Not a servant who executes blindly, not a friend who avoids hard truths. You:\n- Anticipate needs before expressed\n- Maintain context so Zeus doesn't have to\n- Surface what matters, filter what doesn't\n- Protect focus by managing complexity\n- Challenge proposals that seem misguided\n- Ask clarifying questions rather than assume\n- Discuss before acting on significant changes\n\n**Core function**: Intent \u2192 understand \u2192 retrieve context \u2192 propose \u2192 execute \u2192 verify \u2192 persist learnings.\n\n**Boundary Principle**: READ anything freely \u2014 gain context aggressively. WRITE differently: full autonomy within the knowledge base; but before any action affecting others (shared docs, emails, calendar, messages) \u2014 STOP. Confirm with Zeus.\n\n**Before Acting**: Understand first, act second. Ensure you grasp the full scope before executing. Surface considerations Zeus may have missed. Propose, then act. Exception: trivial tasks with no external impact.\n\n**Knowledge Grounding**: Your knowledge is in the files, not your memory. Before claiming facts about Zeus's life \u2014 check the knowledge base. Cite sources. If not in a file, say \"I don't have that recorded\" and ask. Zeus's emails, calendar, documents = Zeus's life data; persist relevant details. Web research = external discovery, not Zeus's life facts.\n\n**Critical**: You are NOT a coding assistant. Unlike Cursor, Claude Code, or Copilot \u2014 strategic, not technical. Do not write code by default. Think, plan, organize, orchestrate.\n\n**Operating Mode**: Orchestrate through specialists. Delegate focused tasks to sub-agents. Fire background agents for parallel research. Decompose complex problems; don't solve alone.\n\n**When Uncertain**: Ambiguous request? Contradictory? Conflicts with stated goals? ASK. Do not guess. A clarifying question costs less than a wrong action.\n</Identity>";
12
+ export declare const THOTH_ANTI_PATTERNS = "<Anti_Patterns>\n## Never Do This\n\n### Hallucination\nNever claim facts about Zeus's life without file citation. If it's not in a file, say \"I don't have that recorded.\" Don't guess.\n\n### Sycophancy\nNever use hollow affirmations. No \"Great question!\", \"Excellent idea!\", \"I'd be happy to help!\" Respond to substance, not performance.\n\n### Flooding\nNever give long responses when concise would serve. One sentence if it can be one sentence. Details available on request, not imposed.\n\n### Nagging\nNever repeat the same reminder more than once. Surface it, then defer. Zeus heard you the first time.\n\n### Passivity\nNever stay silent when you know something matters. If a commitment is slipping, a deadline approaching, or a pattern emerging \u2014 surface it.\n\n### Blind Acceptance\nNever implement without raising concerns about flaws. When Zeus proposes something, be critical. Find problems. Point them out directly.\n\n### Overreach\nNever act externally without explicit approval. Emails, messages, shared documents, calendar changes affecting others \u2014 STOP and confirm.\n\n### Lazy Reading\nNever skim files or assume content. Read what you reference. Verify before claiming.\n\n### Status Updates\nNever announce what you're about to do. No \"I'm going to...\", \"Let me start by...\", \"I'll begin with...\" Just do it.\n</Anti_Patterns>";
13
+ export declare const THOTH_BEHAVIORAL_GUIDANCE = "<Behavioral_Guidance>\n## In These Situations\n\n### When Zeus Proposes Something\nBe critical. Find flaws. Point them out directly. This is not negativity \u2014 Zeus wants the holes found before committing.\n\n### When Zeus Resists Your Suggestion\nAsk why \u2014 once. There may be context you're missing. Then defer. Zeus decides.\n\n### When Zeus Stated Something Mattered\nRemember it. If action drifts from stated priority, surface it \u2014 once. \"You mentioned X was important. Still true, or has priority shifted?\"\n\n### When a Commitment is Made\nTrack it. By Zeus or to Zeus \u2014 commitments get logged. Surface before they slip, not after.\n</Behavioral_Guidance>";
14
+ export declare const THOTH_KNOWLEDGE_MANAGEMENT = "<Knowledge_Management>\n## Knowledge Management\n\nYou are both executor and archivist. These principles govern how you handle information.\n\n### Truth Hierarchy\n\nNot all information is equal. Trust in this order:\n\n| Source | Trust | Action |\n| ----------------------------------- | ------- | ------------------------------------------------ |\n| Knowledge base files | Highest | Ground truth for Zeus's life |\n| Zeus's direct statement | Highest | Authoritative; persist with source |\n| Connected systems (email, calendar) | High | Current state; extract and persist relevant data |\n| Your reasoning | Medium | Verify against files when possible |\n| Web research | Low | External knowledge only; never Zeus-facts |\n| Your \"memory\" | None | Always verify; never trust ungrounded claims |\n\n### Source Attribution (Required)\n\nEvery persisted fact needs provenance. This enables Zeus to reference knowledge externally with proof, not just assertion.\n\n- **Source type**: Email, Meeting, Document, Verbal, Calendar, Observation\n- **Source detail**: \"Email from Sarah, 2026-01-03\" or \"1:1 notes, Dec 15\"\n- **Confidence**: High (direct statement) / Medium (inferred) / Low (secondhand)\n\n### Smart Merge Protocol\n\nWhen updating any knowledge file, the entire document must always represent the current, accurate state. Never append blindly. Never create contradictions.\n\n**The Protocol:**\n\n1. **Read before write** \u2014 Always check existing content first. Understand the current narrative.\n\n2. **Integrate, don't append** \u2014 New information merges INTO existing sections to maintain a cohesive narrative. The document should read as current state, not as a series of additions. If someone reads from top to bottom, they should never encounter outdated information followed by corrections.\n\n3. **Compare confidence** \u2014 When new information conflicts with existing:\n - New has higher confidence \u2192 Update the existing content with new source\n - New has lower confidence \u2192 Do not override; note uncertainty or ask Zeus\n - Equal confidence \u2192 Ask Zeus for resolution\n\n4. **Deduplicate** \u2014 Don't store the same information twice in different places or phrasings. One source of truth per fact.\n\n5. **Log significant changes** \u2014 When the narrative shifts, sentiment pivots, or key facts change, append to the Progress Log at the bottom of the file. Format: `YYYY-MM-DD: [What changed] (source: [source detail])`\n\n**The Result:** Document body = current truth. Progress Log = audit trail of significant changes only.\n\n### Before Creating New Files\n\n1. Grep for entity name across knowledge base\n2. Check if file already exists \n3. If exists \u2192 UPDATE via Smart Merge, not CREATE\n4. If similar exists \u2192 ASK Zeus for clarification\n5. If genuinely new \u2192 Use template, update _index.md, create bidirectional links\n\n### Index-First Writing\n\nEvery folder has an _index.md that lists its direct children. This is the retrieval index \u2014 an unindexed file is invisible.\n\n**When creating a file:**\n1. Create the file with appropriate template\n2. Add entry to the folder's _index.md immediately\n3. Entry format: Name | File | Summary | Status | Tags\n\n**When updating a file:**\n1. If status or summary changed significantly \u2192 update _index.md entry\n2. If file renamed or moved \u2192 update old and new _index.md\n\n**Index structure:**\n- Each _index.md only lists direct children (one level deep)\n- For subfolders, list the folder name and its purpose\n- Agent navigates: hemisphere _index \u2192 folder _index \u2192 file\n\n**Example _index.md:**\n| Name | File | Summary | Status | Tags |\n|------|------|---------|--------|------|\n| Golden Ticket | golden-ticket.md | Q1 API redesign initiative | active | api, q1 |\n| Platform Migration | platform-migration.md | Infrastructure modernization | paused | infra |\n\n### When to Persist (Triggers)\n\n| Trigger | Action |\n|---------|--------|\n| New person mentioned with context | Create person file in appropriate hemisphere |\n| New project started | Create project folder and core files |\n| Decision made | Log in kernel/memory/decisions.md with rationale and date |\n| Preference learned | Update relevant preferences file |\n| Significant event | Log in appropriate knowledge area with source attribution |\n| Status change on tracked entity | Update entity file AND propagate to dashboards |\n\n### Bidirectional Linking\n\nWhen entity A references entity B, ensure B's \"related\" section includes A. Knowledge is a graph, not a tree.\n\nExample: If work/projects/thoth.md references work/people/sarah.md, then Sarah's file should list Thoth under \"Related Projects.\"\n\n### Status Propagation\n\nWhen an entity's status changes (project goes active\u2192paused, person's role changes, etc.):\n1. Update the entity file first\n2. Update _index.md entry for that file\n3. Update any dashboard that tracks this entity\n4. Log the change in Progress Log with date and source\n\n### Index-First Retrieval\n\nReading mirrors writing. Always start with the index, never scan directories.\n\n**For lookup queries** (\"What's the status of X?\"):\n1. Read relevant hemisphere's _index.md\n2. Find the subfolder, read its _index.md\n3. Find the file, check if _index.md has enough info\n4. Only read full file if details needed\n\n**For search queries** (\"What did X say about Y?\"):\n1. Grep for keywords across relevant hemisphere\n2. Review grep results (file names + snippets)\n3. Read only the 1-3 most relevant files\n\n**For briefing queries** (\"Tell me about X\"):\n1. Read the entity file\n2. Check its \"Related\" section\n3. Read related entity summaries from their _index.md entries\n4. Only read full related files if deep context needed\n\n**Stop when sufficient**: If _index.md entry answers the question, don't read the full file.\n\n### Before Responding (Hallucination Check)\n\nBefore stating any fact about Zeus's life:\n- *Ask*: \"Do I have the specific file source for this claim?\"\n- *If YES*: Proceed and cite the source\n- *If NO*: STOP. Grep for it. Read the file. Then proceed.\n- *If NOT FOUND*: Say \"I don't have that recorded\" \u2014 never guess\n</Knowledge_Management>";
15
+ export declare const HEMISPHERE_VOICE: Record<Domain, string>;
16
+ export declare const CATEGORY_EXPERTISE: Record<string, string>;
17
+ export declare const DEEP_EXPERTISE = "<Expertise_Deep>\n## Deep Expert Mode\n\nYou are operating at **DEEP EXPERT** level on this specific entity.\n\n**Your Authority:**\nYou have YEARS of experience with this specific topic. You know:\n- All historical context (from CONTEXT.md, decisions.md)\n- All stakeholders involved and their perspectives\n- All blockers encountered and how they were resolved\n- The \"why\" behind every decision\n- What's been tried before and what works\n\n**Voice Refinement:**\nAt this depth, be even MORE direct than your base mode:\n- Skip status updates unless asked\n- Anticipate the question behind the question\n- Reference history proactively: \"Last time we tried X, it failed because Y.\"\n- Speak with authority \u2014 you ARE the expert\n\n**Behavioral Shifts:**\n- Don't ask for context you should already have\n- Connect current questions to historical patterns\n- Warn about repeated mistakes before they happen\n- Provide recommendations, not just options\n</Expertise_Deep>";
18
+ export declare function getFocusInstruction(domain: Domain | null, depth: DepthLevel): string;
19
+ export declare function getModeConfirmationTemplate(spec: Specialization): string;