@signetai/connector-base 0.140.1

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.
@@ -0,0 +1,159 @@
1
+ /**
2
+ * @signetai/connector-base
3
+ *
4
+ * Base class for Signet harness connectors. Provides shared functionality
5
+ * that all connectors need (Signet block handling, skills symlinking),
6
+ * allowing concrete connectors to focus on harness-specific logic.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { BaseConnector, InstallResult } from '@signetai/connector-base';
11
+ *
12
+ * class MyConnector extends BaseConnector {
13
+ * readonly name = "my-harness";
14
+ * readonly harnessId = "myharness";
15
+ *
16
+ * async install(basePath: string): Promise<InstallResult> {
17
+ * // harness-specific setup
18
+ * }
19
+ *
20
+ * async uninstall(): Promise<void> {
21
+ * // harness-specific cleanup
22
+ * }
23
+ *
24
+ * isInstalled(): boolean {
25
+ * // check if already set up
26
+ * }
27
+ *
28
+ * getConfigPath(): string {
29
+ * // return harness config file path
30
+ * }
31
+ * }
32
+ * ```
33
+ */
34
+ import { type SymlinkOptions, type SymlinkResult } from "@signetai/core";
35
+ export interface InstallResult {
36
+ success: boolean;
37
+ message: string;
38
+ filesWritten: string[];
39
+ configsPatched?: string[];
40
+ warnings?: string[];
41
+ }
42
+ export interface UninstallResult {
43
+ filesRemoved: string[];
44
+ configsPatched?: string[];
45
+ }
46
+ /**
47
+ * Abstract base class for Signet harness connectors.
48
+ *
49
+ * Provides:
50
+ * - stripSignetBlock() - remove existing Signet blocks before re-injection
51
+ * - stripLegacySignetBlock() - migrate old SIGNET block out of AGENTS.md
52
+ * - symlinkSkills() - symlink skills directory to harness-specific location
53
+ *
54
+ * Subclasses must implement:
55
+ * - name - human-readable harness name
56
+ * - harnessId - machine identifier for the harness
57
+ * - install() - harness-specific setup
58
+ * - uninstall() - harness-specific cleanup
59
+ * - isInstalled() - check if integration exists
60
+ * - getConfigPath() - return path to harness config
61
+ */
62
+ export declare abstract class BaseConnector {
63
+ /**
64
+ * Human-readable name for the harness (e.g., "Claude Code")
65
+ */
66
+ abstract readonly name: string;
67
+ /**
68
+ * Machine identifier (e.g., "claude-code")
69
+ */
70
+ abstract readonly harnessId: string;
71
+ /**
72
+ * Strip existing Signet blocks from content.
73
+ *
74
+ * Call this before re-injecting the block to prevent duplication
75
+ * when re-running install or sync operations.
76
+ */
77
+ protected stripSignetBlock(content: string): string;
78
+ /**
79
+ * Strip legacy SIGNET block markers from AGENTS.md in place.
80
+ *
81
+ * Returns the path when a write occurred, otherwise null.
82
+ */
83
+ protected stripLegacySignetBlock(basePath: string): string | null;
84
+ /**
85
+ * Symlink skills from source to target directory.
86
+ *
87
+ * Each subdirectory in sourceDir becomes a symlink in targetDir.
88
+ * Existing symlinks are replaced; real directories are skipped.
89
+ */
90
+ protected symlinkSkills(sourceDir: string, targetDir: string, options?: SymlinkOptions): SymlinkResult;
91
+ /**
92
+ * Generate the auto-generated file header.
93
+ *
94
+ * @param sourcePath - Path to the source file being generated from
95
+ * @param targetName - Name of the target harness
96
+ */
97
+ protected generateHeader(sourcePath: string, targetName?: string): string;
98
+ /**
99
+ * Read and compose additional identity files (SOUL.md, IDENTITY.md,
100
+ * USER.md, MEMORY.md) into a single string with section headers.
101
+ *
102
+ * @param basePath - Path to the Signet workspace or equivalent identity directory
103
+ */
104
+ protected composeIdentityExtras(basePath: string): string;
105
+ /**
106
+ * Install the connector for this harness.
107
+ *
108
+ * Should:
109
+ * - Configure hooks in the harness config
110
+ * - Generate any necessary files (CLAUDE.md, AGENTS.md, etc.)
111
+ * - Set up skills symlinks
112
+ *
113
+ * Must be idempotent - safe to run multiple times.
114
+ */
115
+ abstract install(basePath: string): Promise<InstallResult>;
116
+ /**
117
+ * Remove the connector integration.
118
+ *
119
+ * Should:
120
+ * - Remove hooks from harness config
121
+ * - Remove generated files (but not user data)
122
+ * - Optionally remove skills symlinks
123
+ */
124
+ abstract uninstall(): Promise<UninstallResult>;
125
+ /**
126
+ * Check if the connector is already installed.
127
+ */
128
+ abstract isInstalled(): boolean;
129
+ /**
130
+ * Get the path to the harness's main config file.
131
+ */
132
+ abstract getConfigPath(): string;
133
+ }
134
+ export declare function atomicWriteJson(path: string, data: unknown, indent?: number | string): void;
135
+ export declare const MANAGED_DAEMON_URL_DEFAULT = "http://127.0.0.1:3850";
136
+ export declare const MANAGED_AGENT_ID_DEFAULT = "default";
137
+ export declare function readManagedTrimmedEnv(name: string): string | undefined;
138
+ export declare function resolveSignetWorkspacePath(home?: string): string;
139
+ export declare function resolveSignetDaemonUrl(): string;
140
+ export declare function resolveSignetAgentId(): string;
141
+ export declare function resolveSignetApiKey(): string | undefined;
142
+ export declare function buildManagedExtensionEnvBootstrap(env: {
143
+ readonly signetPath: string;
144
+ readonly daemonUrl: string;
145
+ readonly agentId: string;
146
+ readonly apiKey?: string;
147
+ }): string;
148
+ export declare function managedExtensionFilePath(agentDir: string, filename: string): string;
149
+ export declare function isManagedExtensionFile(filePath: string, marker: string): boolean;
150
+ export declare function removeManagedExtensionFile(filePath: string, marker: string): boolean;
151
+ export interface ConnectorInstallerOptions {
152
+ readonly commandName?: string;
153
+ readonly packageName?: string;
154
+ readonly label?: string;
155
+ }
156
+ type ConnectorConstructor = new () => BaseConnector;
157
+ export declare function runConnectorInstaller(harness: string, ConnectorClass: ConnectorConstructor, options?: ConnectorInstallerOptions): void;
158
+ export type { SymlinkOptions, SymlinkResult };
159
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,aAAa,EAKlB,MAAM,cAAc,CAAC;AAMtB,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,CAA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