panopticon-cli 0.4.28 → 0.4.31
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/{agents-ND4NKCK2.js → agents-GQDAKTEQ.js} +5 -4
- package/dist/{chunk-SIAUVHVO.js → chunk-3XAB4IXF.js} +4 -2
- package/dist/{chunk-SIAUVHVO.js.map → chunk-3XAB4IXF.js.map} +1 -1
- package/dist/chunk-ELK6Q7QI.js +545 -0
- package/dist/chunk-ELK6Q7QI.js.map +1 -0
- package/dist/{chunk-ZLB6G4NW.js → chunk-HNEWTIR3.js} +41 -9
- package/dist/chunk-HNEWTIR3.js.map +1 -0
- package/dist/chunk-LYSBSZYV.js +1523 -0
- package/dist/chunk-LYSBSZYV.js.map +1 -0
- package/dist/{chunk-4KNEZGKZ.js → chunk-TMXN7THF.js} +45 -24
- package/dist/chunk-TMXN7THF.js.map +1 -0
- package/dist/{chunk-ON5NIBGW.js → chunk-VIWUCJ4V.js} +37 -8
- package/dist/chunk-VIWUCJ4V.js.map +1 -0
- package/dist/{chunk-VTMXR7JF.js → chunk-VU4FLXV5.js} +47 -40
- package/dist/{chunk-VTMXR7JF.js.map → chunk-VU4FLXV5.js.map} +1 -1
- package/dist/cli/index.js +153 -86
- package/dist/cli/index.js.map +1 -1
- package/dist/{config-QWTS63TU.js → config-BOAMSKTF.js} +4 -2
- package/dist/dashboard/public/assets/{index--VPaQ2VU.css → index-C7X6LP5Z.css} +1 -1
- package/dist/dashboard/public/assets/{index-GYQaqwVS.js → index-izWbAt7V.js} +152 -152
- package/dist/dashboard/public/index.html +2 -2
- package/dist/dashboard/server.js +94706 -24017
- package/dist/feedback-writer-AAKF5BTK.js +111 -0
- package/dist/feedback-writer-AAKF5BTK.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -14
- package/dist/index.js.map +1 -1
- package/dist/{remote-workspace-FNXLMNBG.js → remote-workspace-2G6V2KNP.js} +7 -5
- package/dist/{remote-workspace-FNXLMNBG.js.map → remote-workspace-2G6V2KNP.js.map} +1 -1
- package/dist/{specialist-context-WXO3FKIB.js → specialist-context-6SE5VRRC.js} +3 -3
- package/dist/{specialist-logs-SJWLETJT.js → specialist-logs-EXLOQHQ2.js} +3 -3
- package/dist/{specialists-5YJIDRW6.js → specialists-BRUHPAXE.js} +3 -3
- package/dist/{traefik-7OLLXUD7.js → traefik-CUJM6K5Z.js} +3 -3
- package/package.json +3 -2
- package/scripts/record-cost-event.js +243 -79
- package/scripts/record-cost-event.ts +128 -68
- package/templates/traefik/docker-compose.yml +7 -4
- package/templates/traefik/dynamic/panopticon.yml.template +3 -1
- package/dist/chunk-46DPNFMW.js +0 -278
- package/dist/chunk-46DPNFMW.js.map +0 -1
- package/dist/chunk-4KNEZGKZ.js.map +0 -1
- package/dist/chunk-ON5NIBGW.js.map +0 -1
- package/dist/chunk-SUMIHS2B.js +0 -1714
- package/dist/chunk-SUMIHS2B.js.map +0 -1
- package/dist/chunk-ZLB6G4NW.js.map +0 -1
- /package/dist/{agents-ND4NKCK2.js.map → agents-GQDAKTEQ.js.map} +0 -0
- /package/dist/{config-QWTS63TU.js.map → config-BOAMSKTF.js.map} +0 -0
- /package/dist/{specialist-context-WXO3FKIB.js.map → specialist-context-6SE5VRRC.js.map} +0 -0
- /package/dist/{specialist-logs-SJWLETJT.js.map → specialist-logs-EXLOQHQ2.js.map} +0 -0
- /package/dist/{specialists-5YJIDRW6.js.map → specialists-BRUHPAXE.js.map} +0 -0
- /package/dist/{traefik-7OLLXUD7.js.map → traefik-CUJM6K5Z.js.map} +0 -0
|
@@ -17,10 +17,11 @@ import {
|
|
|
17
17
|
saveSessionId,
|
|
18
18
|
spawnAgent,
|
|
19
19
|
stopAgent
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-HNEWTIR3.js";
|
|
21
|
+
import "./chunk-VIWUCJ4V.js";
|
|
22
|
+
import "./chunk-LYSBSZYV.js";
|
|
23
23
|
import "./chunk-BBCUK6N2.js";
|
|
24
|
+
import "./chunk-VU4FLXV5.js";
|
|
24
25
|
import "./chunk-6HXKTOD7.js";
|
|
25
26
|
import "./chunk-ZHC57RCV.js";
|
|
26
27
|
init_agents();
|
|
@@ -43,4 +44,4 @@ export {
|
|
|
43
44
|
spawnAgent,
|
|
44
45
|
stopAgent
|
|
45
46
|
};
|
|
46
|
-
//# sourceMappingURL=agents-
|
|
47
|
+
//# sourceMappingURL=agents-GQDAKTEQ.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
init_config,
|
|
2
3
|
loadConfig
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VU4FLXV5.js";
|
|
4
5
|
import {
|
|
5
6
|
SOURCE_TRAEFIK_TEMPLATES,
|
|
6
7
|
TRAEFIK_DYNAMIC_DIR,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
// src/lib/traefik.ts
|
|
14
15
|
init_esm_shims();
|
|
15
16
|
init_paths();
|
|
17
|
+
init_config();
|
|
16
18
|
import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync } from "fs";
|
|
17
19
|
import { join } from "path";
|
|
18
20
|
function generatePanopticonTraefikConfig() {
|
|
@@ -46,4 +48,4 @@ export {
|
|
|
46
48
|
generatePanopticonTraefikConfig,
|
|
47
49
|
cleanupTemplateFiles
|
|
48
50
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-3XAB4IXF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/traefik.ts"],"sourcesContent":["/**\n * Traefik Configuration Generator\n *\n * Generates the Panopticon dashboard Traefik routing config\n * from a template, substituting values from config.toml.\n */\n\nimport { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync } from 'fs';\nimport { join } from 'path';\nimport { TRAEFIK_DYNAMIC_DIR, SOURCE_TRAEFIK_TEMPLATES } from './paths.js';\nimport { loadConfig } from './config.js';\n\n/**\n * Generate panopticon.yml from template using current config values.\n * Safe to call multiple times (idempotent).\n * Returns true if file was written, false if template not found.\n */\nexport function generatePanopticonTraefikConfig(): boolean {\n const templatePath = join(SOURCE_TRAEFIK_TEMPLATES, 'dynamic', 'panopticon.yml.template');\n if (!existsSync(templatePath)) {\n return false;\n }\n\n const config = loadConfig();\n const placeholders: Record<string, string> = {\n TRAEFIK_DOMAIN: config.traefik?.domain || 'pan.localhost',\n DASHBOARD_PORT: String(config.dashboard.port),\n DASHBOARD_API_PORT: String(config.dashboard.api_port),\n };\n\n let content = readFileSync(templatePath, 'utf-8');\n for (const [key, value] of Object.entries(placeholders)) {\n content = content.replace(new RegExp(`\\\\{\\\\{${key}\\\\}\\\\}`, 'g'), value);\n }\n\n mkdirSync(TRAEFIK_DYNAMIC_DIR, { recursive: true });\n const outputPath = join(TRAEFIK_DYNAMIC_DIR, 'panopticon.yml');\n writeFileSync(outputPath, content, 'utf-8');\n return true;\n}\n\n/**\n * Remove any accidentally-copied .template files from the runtime Traefik dir.\n * Called after copyDirectoryRecursive in pan install.\n */\nexport function cleanupTemplateFiles(): void {\n const copiedTemplate = join(TRAEFIK_DYNAMIC_DIR, 'panopticon.yml.template');\n if (existsSync(copiedTemplate)) {\n unlinkSync(copiedTemplate);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/lib/traefik.ts"],"sourcesContent":["/**\n * Traefik Configuration Generator\n *\n * Generates the Panopticon dashboard Traefik routing config\n * from a template, substituting values from config.toml.\n */\n\nimport { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync } from 'fs';\nimport { join } from 'path';\nimport { TRAEFIK_DYNAMIC_DIR, SOURCE_TRAEFIK_TEMPLATES } from './paths.js';\nimport { loadConfig } from './config.js';\n\n/**\n * Generate panopticon.yml from template using current config values.\n * Safe to call multiple times (idempotent).\n * Returns true if file was written, false if template not found.\n */\nexport function generatePanopticonTraefikConfig(): boolean {\n const templatePath = join(SOURCE_TRAEFIK_TEMPLATES, 'dynamic', 'panopticon.yml.template');\n if (!existsSync(templatePath)) {\n return false;\n }\n\n const config = loadConfig();\n const placeholders: Record<string, string> = {\n TRAEFIK_DOMAIN: config.traefik?.domain || 'pan.localhost',\n DASHBOARD_PORT: String(config.dashboard.port),\n DASHBOARD_API_PORT: String(config.dashboard.api_port),\n };\n\n let content = readFileSync(templatePath, 'utf-8');\n for (const [key, value] of Object.entries(placeholders)) {\n content = content.replace(new RegExp(`\\\\{\\\\{${key}\\\\}\\\\}`, 'g'), value);\n }\n\n mkdirSync(TRAEFIK_DYNAMIC_DIR, { recursive: true });\n const outputPath = join(TRAEFIK_DYNAMIC_DIR, 'panopticon.yml');\n writeFileSync(outputPath, content, 'utf-8');\n return true;\n}\n\n/**\n * Remove any accidentally-copied .template files from the runtime Traefik dir.\n * Called after copyDirectoryRecursive in pan install.\n */\nexport function cleanupTemplateFiles(): void {\n const copiedTemplate = join(TRAEFIK_DYNAMIC_DIR, 'panopticon.yml.template');\n if (existsSync(copiedTemplate)) {\n unlinkSync(copiedTemplate);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AASA;AACA;AAHA,SAAS,YAAY,cAAc,eAAe,WAAW,kBAAkB;AAC/E,SAAS,YAAY;AASd,SAAS,kCAA2C;AACzD,QAAM,eAAe,KAAK,0BAA0B,WAAW,yBAAyB;AACxF,MAAI,CAAC,WAAW,YAAY,GAAG;AAC7B,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,WAAW;AAC1B,QAAM,eAAuC;AAAA,IAC3C,gBAAgB,OAAO,SAAS,UAAU;AAAA,IAC1C,gBAAgB,OAAO,OAAO,UAAU,IAAI;AAAA,IAC5C,oBAAoB,OAAO,OAAO,UAAU,QAAQ;AAAA,EACtD;AAEA,MAAI,UAAU,aAAa,cAAc,OAAO;AAChD,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,YAAY,GAAG;AACvD,cAAU,QAAQ,QAAQ,IAAI,OAAO,SAAS,GAAG,UAAU,GAAG,GAAG,KAAK;AAAA,EACxE;AAEA,YAAU,qBAAqB,EAAE,WAAW,KAAK,CAAC;AAClD,QAAM,aAAa,KAAK,qBAAqB,gBAAgB;AAC7D,gBAAc,YAAY,SAAS,OAAO;AAC1C,SAAO;AACT;AAMO,SAAS,uBAA6B;AAC3C,QAAM,iBAAiB,KAAK,qBAAqB,yBAAyB;AAC1E,MAAI,WAAW,cAAc,GAAG;AAC9B,eAAW,cAAc;AAAA,EAC3B;AACF;","names":[]}
|
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_factory,
|
|
3
|
+
init_github,
|
|
4
|
+
init_gitlab,
|
|
5
|
+
init_interface,
|
|
6
|
+
init_linear
|
|
7
|
+
} from "./chunk-LYSBSZYV.js";
|
|
8
|
+
import {
|
|
9
|
+
AGENTS_DIR,
|
|
10
|
+
BACKUPS_DIR,
|
|
11
|
+
BIN_DIR,
|
|
12
|
+
COMMANDS_DIR,
|
|
13
|
+
SKILLS_DIR,
|
|
14
|
+
SOURCE_DEV_SKILLS_DIR,
|
|
15
|
+
SOURCE_SCRIPTS_DIR,
|
|
16
|
+
SYNC_TARGETS,
|
|
17
|
+
init_paths,
|
|
18
|
+
isDevMode
|
|
19
|
+
} from "./chunk-6HXKTOD7.js";
|
|
20
|
+
import {
|
|
21
|
+
init_esm_shims
|
|
22
|
+
} from "./chunk-ZHC57RCV.js";
|
|
23
|
+
|
|
24
|
+
// src/lib/shell.ts
|
|
25
|
+
init_esm_shims();
|
|
26
|
+
import { existsSync, readFileSync, appendFileSync } from "fs";
|
|
27
|
+
import { homedir } from "os";
|
|
28
|
+
import { join } from "path";
|
|
29
|
+
function detectShell() {
|
|
30
|
+
const shell = process.env.SHELL || "";
|
|
31
|
+
if (shell.includes("zsh")) return "zsh";
|
|
32
|
+
if (shell.includes("bash")) return "bash";
|
|
33
|
+
if (shell.includes("fish")) return "fish";
|
|
34
|
+
return "unknown";
|
|
35
|
+
}
|
|
36
|
+
function getShellRcFile(shell) {
|
|
37
|
+
const home = homedir();
|
|
38
|
+
switch (shell) {
|
|
39
|
+
case "zsh":
|
|
40
|
+
return join(home, ".zshrc");
|
|
41
|
+
case "bash":
|
|
42
|
+
const bashrc = join(home, ".bashrc");
|
|
43
|
+
if (existsSync(bashrc)) return bashrc;
|
|
44
|
+
return join(home, ".bash_profile");
|
|
45
|
+
case "fish":
|
|
46
|
+
return join(home, ".config", "fish", "config.fish");
|
|
47
|
+
default:
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
var ALIAS_LINE = 'alias pan="panopticon"';
|
|
52
|
+
var ALIAS_MARKER = "# Panopticon CLI alias";
|
|
53
|
+
function hasAlias(rcFile) {
|
|
54
|
+
if (!existsSync(rcFile)) return false;
|
|
55
|
+
const content = readFileSync(rcFile, "utf8");
|
|
56
|
+
return content.includes(ALIAS_MARKER) || content.includes(ALIAS_LINE);
|
|
57
|
+
}
|
|
58
|
+
function addAlias(rcFile) {
|
|
59
|
+
if (hasAlias(rcFile)) return;
|
|
60
|
+
const aliasBlock = `
|
|
61
|
+
${ALIAS_MARKER}
|
|
62
|
+
${ALIAS_LINE}
|
|
63
|
+
`;
|
|
64
|
+
appendFileSync(rcFile, aliasBlock, "utf8");
|
|
65
|
+
}
|
|
66
|
+
function getAliasInstructions(shell) {
|
|
67
|
+
const rcFile = getShellRcFile(shell);
|
|
68
|
+
if (!rcFile) {
|
|
69
|
+
return `Add this to your shell config:
|
|
70
|
+
${ALIAS_LINE}`;
|
|
71
|
+
}
|
|
72
|
+
return `Alias added to ${rcFile}. Run:
|
|
73
|
+
source ${rcFile}`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/lib/backup.ts
|
|
77
|
+
init_esm_shims();
|
|
78
|
+
init_paths();
|
|
79
|
+
import { existsSync as existsSync2, mkdirSync, readdirSync, cpSync, rmSync, lstatSync } from "fs";
|
|
80
|
+
import { join as join2, basename } from "path";
|
|
81
|
+
function createBackupTimestamp() {
|
|
82
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
83
|
+
}
|
|
84
|
+
function createBackup(sourceDirs) {
|
|
85
|
+
const timestamp = createBackupTimestamp();
|
|
86
|
+
const backupPath = join2(BACKUPS_DIR, timestamp);
|
|
87
|
+
mkdirSync(backupPath, { recursive: true });
|
|
88
|
+
const targets = [];
|
|
89
|
+
for (const sourceDir of sourceDirs) {
|
|
90
|
+
if (!existsSync2(sourceDir)) continue;
|
|
91
|
+
const targetName = basename(sourceDir);
|
|
92
|
+
const targetPath = join2(backupPath, targetName);
|
|
93
|
+
cpSync(sourceDir, targetPath, {
|
|
94
|
+
recursive: true,
|
|
95
|
+
filter: (src) => !lstatSync(src).isSymbolicLink()
|
|
96
|
+
});
|
|
97
|
+
targets.push(targetName);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
timestamp,
|
|
101
|
+
path: backupPath,
|
|
102
|
+
targets
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function listBackups() {
|
|
106
|
+
if (!existsSync2(BACKUPS_DIR)) return [];
|
|
107
|
+
const entries = readdirSync(BACKUPS_DIR, { withFileTypes: true });
|
|
108
|
+
return entries.filter((e) => e.isDirectory()).map((e) => {
|
|
109
|
+
const backupPath = join2(BACKUPS_DIR, e.name);
|
|
110
|
+
const contents = readdirSync(backupPath);
|
|
111
|
+
return {
|
|
112
|
+
timestamp: e.name,
|
|
113
|
+
path: backupPath,
|
|
114
|
+
targets: contents
|
|
115
|
+
};
|
|
116
|
+
}).sort((a, b) => b.timestamp.localeCompare(a.timestamp));
|
|
117
|
+
}
|
|
118
|
+
function restoreBackup(timestamp, targetDirs) {
|
|
119
|
+
const backupPath = join2(BACKUPS_DIR, timestamp);
|
|
120
|
+
if (!existsSync2(backupPath)) {
|
|
121
|
+
throw new Error(`Backup not found: ${timestamp}`);
|
|
122
|
+
}
|
|
123
|
+
const contents = readdirSync(backupPath, { withFileTypes: true });
|
|
124
|
+
for (const entry of contents) {
|
|
125
|
+
if (!entry.isDirectory()) continue;
|
|
126
|
+
const sourcePath = join2(backupPath, entry.name);
|
|
127
|
+
const targetPath = targetDirs[entry.name];
|
|
128
|
+
if (!targetPath) continue;
|
|
129
|
+
if (existsSync2(targetPath)) {
|
|
130
|
+
rmSync(targetPath, { recursive: true });
|
|
131
|
+
}
|
|
132
|
+
cpSync(sourcePath, targetPath, { recursive: true });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function cleanOldBackups(keepCount = 10) {
|
|
136
|
+
const backups = listBackups();
|
|
137
|
+
if (backups.length <= keepCount) return 0;
|
|
138
|
+
const toRemove = backups.slice(keepCount);
|
|
139
|
+
let removed = 0;
|
|
140
|
+
for (const backup of toRemove) {
|
|
141
|
+
rmSync(backup.path, { recursive: true });
|
|
142
|
+
removed++;
|
|
143
|
+
}
|
|
144
|
+
return removed;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/lib/sync.ts
|
|
148
|
+
init_esm_shims();
|
|
149
|
+
init_paths();
|
|
150
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readdirSync as readdirSync2, symlinkSync, unlinkSync, lstatSync as lstatSync2, readlinkSync, rmSync as rmSync2, copyFileSync, chmodSync } from "fs";
|
|
151
|
+
import { join as join3 } from "path";
|
|
152
|
+
function removeTarget(targetPath) {
|
|
153
|
+
const stats = lstatSync2(targetPath);
|
|
154
|
+
if (stats.isDirectory() && !stats.isSymbolicLink()) {
|
|
155
|
+
rmSync2(targetPath, { recursive: true, force: true });
|
|
156
|
+
} else {
|
|
157
|
+
unlinkSync(targetPath);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function isPanopticonSymlink(targetPath) {
|
|
161
|
+
if (!existsSync3(targetPath)) return false;
|
|
162
|
+
try {
|
|
163
|
+
const stats = lstatSync2(targetPath);
|
|
164
|
+
if (!stats.isSymbolicLink()) return false;
|
|
165
|
+
const linkTarget = readlinkSync(targetPath);
|
|
166
|
+
return linkTarget.includes(".panopticon");
|
|
167
|
+
} catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function planSync(runtime) {
|
|
172
|
+
const targets = SYNC_TARGETS[runtime];
|
|
173
|
+
if (!targets) {
|
|
174
|
+
throw new Error(`Unknown sync target "${runtime}". Valid targets: ${Object.keys(SYNC_TARGETS).join(", ")}`);
|
|
175
|
+
}
|
|
176
|
+
const plan = {
|
|
177
|
+
runtime,
|
|
178
|
+
skills: [],
|
|
179
|
+
commands: [],
|
|
180
|
+
agents: [],
|
|
181
|
+
devSkills: []
|
|
182
|
+
};
|
|
183
|
+
if (existsSync3(SKILLS_DIR)) {
|
|
184
|
+
const skills = readdirSync2(SKILLS_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
185
|
+
for (const skill of skills) {
|
|
186
|
+
const sourcePath = join3(SKILLS_DIR, skill.name);
|
|
187
|
+
const targetPath = join3(targets.skills, skill.name);
|
|
188
|
+
let status = "new";
|
|
189
|
+
if (existsSync3(targetPath)) {
|
|
190
|
+
if (isPanopticonSymlink(targetPath)) {
|
|
191
|
+
status = "symlink";
|
|
192
|
+
} else {
|
|
193
|
+
status = "conflict";
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
plan.skills.push({ name: skill.name, sourcePath, targetPath, status });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (isDevMode() && existsSync3(SOURCE_DEV_SKILLS_DIR)) {
|
|
200
|
+
const devSkills = readdirSync2(SOURCE_DEV_SKILLS_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
201
|
+
for (const skill of devSkills) {
|
|
202
|
+
const sourcePath = join3(SOURCE_DEV_SKILLS_DIR, skill.name);
|
|
203
|
+
const targetPath = join3(targets.skills, skill.name);
|
|
204
|
+
let status = "new";
|
|
205
|
+
if (existsSync3(targetPath)) {
|
|
206
|
+
if (isPanopticonSymlink(targetPath)) {
|
|
207
|
+
status = "symlink";
|
|
208
|
+
} else {
|
|
209
|
+
status = "conflict";
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
plan.devSkills.push({ name: skill.name, sourcePath, targetPath, status });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (existsSync3(COMMANDS_DIR)) {
|
|
216
|
+
const commands = readdirSync2(COMMANDS_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
217
|
+
for (const cmd of commands) {
|
|
218
|
+
const sourcePath = join3(COMMANDS_DIR, cmd.name);
|
|
219
|
+
const targetPath = join3(targets.commands, cmd.name);
|
|
220
|
+
let status = "new";
|
|
221
|
+
if (existsSync3(targetPath)) {
|
|
222
|
+
if (isPanopticonSymlink(targetPath)) {
|
|
223
|
+
status = "symlink";
|
|
224
|
+
} else {
|
|
225
|
+
status = "conflict";
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
plan.commands.push({ name: cmd.name, sourcePath, targetPath, status });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (existsSync3(AGENTS_DIR)) {
|
|
232
|
+
const agents = readdirSync2(AGENTS_DIR, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".md"));
|
|
233
|
+
for (const agent of agents) {
|
|
234
|
+
const sourcePath = join3(AGENTS_DIR, agent.name);
|
|
235
|
+
const targetPath = join3(targets.agents, agent.name);
|
|
236
|
+
let status = "new";
|
|
237
|
+
if (existsSync3(targetPath)) {
|
|
238
|
+
if (isPanopticonSymlink(targetPath)) {
|
|
239
|
+
status = "symlink";
|
|
240
|
+
} else {
|
|
241
|
+
status = "conflict";
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
plan.agents.push({ name: agent.name, sourcePath, targetPath, status });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return plan;
|
|
248
|
+
}
|
|
249
|
+
function executeSync(runtime, options = {}) {
|
|
250
|
+
const targets = SYNC_TARGETS[runtime];
|
|
251
|
+
if (!targets) {
|
|
252
|
+
throw new Error(`Unknown sync target "${runtime}". Valid targets: ${Object.keys(SYNC_TARGETS).join(", ")}`);
|
|
253
|
+
}
|
|
254
|
+
const plan = planSync(runtime);
|
|
255
|
+
const result = {
|
|
256
|
+
created: [],
|
|
257
|
+
skipped: [],
|
|
258
|
+
conflicts: []
|
|
259
|
+
};
|
|
260
|
+
mkdirSync2(targets.skills, { recursive: true });
|
|
261
|
+
mkdirSync2(targets.commands, { recursive: true });
|
|
262
|
+
mkdirSync2(targets.agents, { recursive: true });
|
|
263
|
+
for (const item of plan.skills) {
|
|
264
|
+
if (options.dryRun) {
|
|
265
|
+
if (item.status === "new" || item.status === "symlink") {
|
|
266
|
+
result.created.push(item.name);
|
|
267
|
+
} else {
|
|
268
|
+
result.conflicts.push(item.name);
|
|
269
|
+
}
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (item.status === "conflict" && !options.force) {
|
|
273
|
+
result.conflicts.push(item.name);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (existsSync3(item.targetPath)) {
|
|
277
|
+
removeTarget(item.targetPath);
|
|
278
|
+
}
|
|
279
|
+
symlinkSync(item.sourcePath, item.targetPath);
|
|
280
|
+
result.created.push(item.name);
|
|
281
|
+
}
|
|
282
|
+
for (const item of plan.commands) {
|
|
283
|
+
if (options.dryRun) {
|
|
284
|
+
if (item.status === "new" || item.status === "symlink") {
|
|
285
|
+
result.created.push(item.name);
|
|
286
|
+
} else {
|
|
287
|
+
result.conflicts.push(item.name);
|
|
288
|
+
}
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (item.status === "conflict" && !options.force) {
|
|
292
|
+
result.conflicts.push(item.name);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (existsSync3(item.targetPath)) {
|
|
296
|
+
removeTarget(item.targetPath);
|
|
297
|
+
}
|
|
298
|
+
symlinkSync(item.sourcePath, item.targetPath);
|
|
299
|
+
result.created.push(item.name);
|
|
300
|
+
}
|
|
301
|
+
for (const item of plan.agents) {
|
|
302
|
+
if (options.dryRun) {
|
|
303
|
+
if (item.status === "new" || item.status === "symlink") {
|
|
304
|
+
result.created.push(item.name);
|
|
305
|
+
} else {
|
|
306
|
+
result.conflicts.push(item.name);
|
|
307
|
+
}
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (item.status === "conflict" && !options.force) {
|
|
311
|
+
result.conflicts.push(item.name);
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (existsSync3(item.targetPath)) {
|
|
315
|
+
removeTarget(item.targetPath);
|
|
316
|
+
}
|
|
317
|
+
symlinkSync(item.sourcePath, item.targetPath);
|
|
318
|
+
result.created.push(item.name);
|
|
319
|
+
}
|
|
320
|
+
for (const item of plan.devSkills) {
|
|
321
|
+
if (options.dryRun) {
|
|
322
|
+
if (item.status === "new" || item.status === "symlink") {
|
|
323
|
+
result.created.push(`${item.name} (dev)`);
|
|
324
|
+
} else {
|
|
325
|
+
result.conflicts.push(`${item.name} (dev)`);
|
|
326
|
+
}
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (item.status === "conflict" && !options.force) {
|
|
330
|
+
result.conflicts.push(`${item.name} (dev)`);
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (existsSync3(item.targetPath)) {
|
|
334
|
+
removeTarget(item.targetPath);
|
|
335
|
+
}
|
|
336
|
+
symlinkSync(item.sourcePath, item.targetPath);
|
|
337
|
+
result.created.push(`${item.name} (dev)`);
|
|
338
|
+
}
|
|
339
|
+
return result;
|
|
340
|
+
}
|
|
341
|
+
function planHooksSync() {
|
|
342
|
+
const hooks = [];
|
|
343
|
+
if (!existsSync3(SOURCE_SCRIPTS_DIR)) {
|
|
344
|
+
return hooks;
|
|
345
|
+
}
|
|
346
|
+
const scripts = readdirSync2(SOURCE_SCRIPTS_DIR, { withFileTypes: true }).filter((entry) => entry.isFile() && !entry.name.startsWith(".") && (!entry.name.includes(".") || entry.name.endsWith(".js")));
|
|
347
|
+
for (const script of scripts) {
|
|
348
|
+
const sourcePath = join3(SOURCE_SCRIPTS_DIR, script.name);
|
|
349
|
+
const targetPath = join3(BIN_DIR, script.name);
|
|
350
|
+
let status = "new";
|
|
351
|
+
if (existsSync3(targetPath)) {
|
|
352
|
+
status = "updated";
|
|
353
|
+
}
|
|
354
|
+
hooks.push({ name: script.name, sourcePath, targetPath, status });
|
|
355
|
+
}
|
|
356
|
+
return hooks;
|
|
357
|
+
}
|
|
358
|
+
function syncHooks() {
|
|
359
|
+
const result = { synced: [], errors: [] };
|
|
360
|
+
mkdirSync2(BIN_DIR, { recursive: true });
|
|
361
|
+
const hooks = planHooksSync();
|
|
362
|
+
for (const hook of hooks) {
|
|
363
|
+
try {
|
|
364
|
+
copyFileSync(hook.sourcePath, hook.targetPath);
|
|
365
|
+
chmodSync(hook.targetPath, 493);
|
|
366
|
+
result.synced.push(hook.name);
|
|
367
|
+
} catch (error) {
|
|
368
|
+
result.errors.push(`${hook.name}: ${error}`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// src/lib/tracker/linking.ts
|
|
375
|
+
init_esm_shims();
|
|
376
|
+
import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync4, mkdirSync as mkdirSync3 } from "fs";
|
|
377
|
+
import { join as join4 } from "path";
|
|
378
|
+
import { homedir as homedir2 } from "os";
|
|
379
|
+
function parseIssueRef(ref) {
|
|
380
|
+
if (ref.startsWith("github#")) {
|
|
381
|
+
return { tracker: "github", ref: `#${ref.slice(7)}` };
|
|
382
|
+
}
|
|
383
|
+
if (ref.startsWith("gitlab#")) {
|
|
384
|
+
return { tracker: "gitlab", ref: `#${ref.slice(7)}` };
|
|
385
|
+
}
|
|
386
|
+
if (ref.startsWith("linear:")) {
|
|
387
|
+
return { tracker: "linear", ref: ref.slice(7) };
|
|
388
|
+
}
|
|
389
|
+
if (/^#\d+$/.test(ref)) {
|
|
390
|
+
return { tracker: "github", ref };
|
|
391
|
+
}
|
|
392
|
+
if (/^[A-Z]+-\d+$/i.test(ref)) {
|
|
393
|
+
return { tracker: "linear", ref: ref.toUpperCase() };
|
|
394
|
+
}
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
function formatIssueRef(ref, tracker) {
|
|
398
|
+
if (tracker === "github") {
|
|
399
|
+
return ref.startsWith("#") ? `github${ref}` : `github#${ref}`;
|
|
400
|
+
}
|
|
401
|
+
if (tracker === "gitlab") {
|
|
402
|
+
return ref.startsWith("#") ? `gitlab${ref}` : `gitlab#${ref}`;
|
|
403
|
+
}
|
|
404
|
+
return ref;
|
|
405
|
+
}
|
|
406
|
+
var LinkManager = class {
|
|
407
|
+
storePath;
|
|
408
|
+
store;
|
|
409
|
+
constructor(storePath) {
|
|
410
|
+
this.storePath = storePath ?? join4(homedir2(), ".panopticon", "links.json");
|
|
411
|
+
this.store = this.load();
|
|
412
|
+
}
|
|
413
|
+
load() {
|
|
414
|
+
if (existsSync4(this.storePath)) {
|
|
415
|
+
try {
|
|
416
|
+
const data = JSON.parse(readFileSync2(this.storePath, "utf-8"));
|
|
417
|
+
if (data.version === 1) {
|
|
418
|
+
return data;
|
|
419
|
+
}
|
|
420
|
+
} catch {
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return { version: 1, links: [] };
|
|
424
|
+
}
|
|
425
|
+
save() {
|
|
426
|
+
const dir = join4(this.storePath, "..");
|
|
427
|
+
if (!existsSync4(dir)) {
|
|
428
|
+
mkdirSync3(dir, { recursive: true });
|
|
429
|
+
}
|
|
430
|
+
writeFileSync(this.storePath, JSON.stringify(this.store, null, 2));
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Add a link between two issues
|
|
434
|
+
*/
|
|
435
|
+
addLink(source, target, direction = "related") {
|
|
436
|
+
const existing = this.store.links.find(
|
|
437
|
+
(l) => l.sourceIssueRef === source.ref && l.sourceTracker === source.tracker && l.targetIssueRef === target.ref && l.targetTracker === target.tracker
|
|
438
|
+
);
|
|
439
|
+
if (existing) {
|
|
440
|
+
if (existing.direction !== direction) {
|
|
441
|
+
existing.direction = direction;
|
|
442
|
+
this.save();
|
|
443
|
+
}
|
|
444
|
+
return existing;
|
|
445
|
+
}
|
|
446
|
+
const link = {
|
|
447
|
+
sourceIssueRef: source.ref,
|
|
448
|
+
sourceTracker: source.tracker,
|
|
449
|
+
targetIssueRef: target.ref,
|
|
450
|
+
targetTracker: target.tracker,
|
|
451
|
+
direction,
|
|
452
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
453
|
+
};
|
|
454
|
+
this.store.links.push(link);
|
|
455
|
+
this.save();
|
|
456
|
+
return link;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Remove a link between two issues
|
|
460
|
+
*/
|
|
461
|
+
removeLink(source, target) {
|
|
462
|
+
const index = this.store.links.findIndex(
|
|
463
|
+
(l) => l.sourceIssueRef === source.ref && l.sourceTracker === source.tracker && l.targetIssueRef === target.ref && l.targetTracker === target.tracker
|
|
464
|
+
);
|
|
465
|
+
if (index >= 0) {
|
|
466
|
+
this.store.links.splice(index, 1);
|
|
467
|
+
this.save();
|
|
468
|
+
return true;
|
|
469
|
+
}
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Get all issues linked to a given issue
|
|
474
|
+
*/
|
|
475
|
+
getLinkedIssues(ref, tracker) {
|
|
476
|
+
return this.store.links.filter(
|
|
477
|
+
(l) => l.sourceIssueRef === ref && l.sourceTracker === tracker || l.targetIssueRef === ref && l.targetTracker === tracker
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Get all links (for debugging/admin)
|
|
482
|
+
*/
|
|
483
|
+
getAllLinks() {
|
|
484
|
+
return [...this.store.links];
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Find linked issue in another tracker
|
|
488
|
+
*/
|
|
489
|
+
findLinkedIssue(ref, sourceTracker, targetTracker) {
|
|
490
|
+
const asSource = this.store.links.find(
|
|
491
|
+
(l) => l.sourceIssueRef === ref && l.sourceTracker === sourceTracker && l.targetTracker === targetTracker
|
|
492
|
+
);
|
|
493
|
+
if (asSource) return asSource.targetIssueRef;
|
|
494
|
+
const asTarget = this.store.links.find(
|
|
495
|
+
(l) => l.targetIssueRef === ref && l.targetTracker === sourceTracker && l.sourceTracker === targetTracker
|
|
496
|
+
);
|
|
497
|
+
if (asTarget) return asTarget.sourceIssueRef;
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Clear all links (for testing)
|
|
502
|
+
*/
|
|
503
|
+
clear() {
|
|
504
|
+
this.store.links = [];
|
|
505
|
+
this.save();
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
var _linkManager = null;
|
|
509
|
+
function getLinkManager() {
|
|
510
|
+
if (!_linkManager) {
|
|
511
|
+
_linkManager = new LinkManager();
|
|
512
|
+
}
|
|
513
|
+
return _linkManager;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// src/lib/tracker/index.ts
|
|
517
|
+
init_esm_shims();
|
|
518
|
+
init_interface();
|
|
519
|
+
init_linear();
|
|
520
|
+
init_github();
|
|
521
|
+
init_gitlab();
|
|
522
|
+
init_factory();
|
|
523
|
+
|
|
524
|
+
export {
|
|
525
|
+
detectShell,
|
|
526
|
+
getShellRcFile,
|
|
527
|
+
hasAlias,
|
|
528
|
+
addAlias,
|
|
529
|
+
getAliasInstructions,
|
|
530
|
+
createBackupTimestamp,
|
|
531
|
+
createBackup,
|
|
532
|
+
listBackups,
|
|
533
|
+
restoreBackup,
|
|
534
|
+
cleanOldBackups,
|
|
535
|
+
isPanopticonSymlink,
|
|
536
|
+
planSync,
|
|
537
|
+
executeSync,
|
|
538
|
+
planHooksSync,
|
|
539
|
+
syncHooks,
|
|
540
|
+
parseIssueRef,
|
|
541
|
+
formatIssueRef,
|
|
542
|
+
LinkManager,
|
|
543
|
+
getLinkManager
|
|
544
|
+
};
|
|
545
|
+
//# sourceMappingURL=chunk-ELK6Q7QI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/shell.ts","../src/lib/backup.ts","../src/lib/sync.ts","../src/lib/tracker/linking.ts","../src/lib/tracker/index.ts"],"sourcesContent":["import { existsSync, readFileSync, appendFileSync } from 'fs';\nimport { homedir } from 'os';\nimport { join } from 'path';\n\nexport type Shell = 'bash' | 'zsh' | 'fish' | 'unknown';\n\nexport function detectShell(): Shell {\n const shell = process.env.SHELL || '';\n\n if (shell.includes('zsh')) return 'zsh';\n if (shell.includes('bash')) return 'bash';\n if (shell.includes('fish')) return 'fish';\n\n return 'unknown';\n}\n\nexport function getShellRcFile(shell: Shell): string | null {\n const home = homedir();\n\n switch (shell) {\n case 'zsh':\n return join(home, '.zshrc');\n case 'bash':\n // Prefer .bashrc, fall back to .bash_profile\n const bashrc = join(home, '.bashrc');\n if (existsSync(bashrc)) return bashrc;\n return join(home, '.bash_profile');\n case 'fish':\n return join(home, '.config', 'fish', 'config.fish');\n default:\n return null;\n }\n}\n\nconst ALIAS_LINE = 'alias pan=\"panopticon\"';\nconst ALIAS_MARKER = '# Panopticon CLI alias';\n\nexport function hasAlias(rcFile: string): boolean {\n if (!existsSync(rcFile)) return false;\n\n const content = readFileSync(rcFile, 'utf8');\n return content.includes(ALIAS_MARKER) || content.includes(ALIAS_LINE);\n}\n\nexport function addAlias(rcFile: string): void {\n if (hasAlias(rcFile)) return;\n\n const aliasBlock = `\n${ALIAS_MARKER}\n${ALIAS_LINE}\n`;\n\n appendFileSync(rcFile, aliasBlock, 'utf8');\n}\n\nexport function getAliasInstructions(shell: Shell): string {\n const rcFile = getShellRcFile(shell);\n\n if (!rcFile) {\n return `Add this to your shell config:\\n ${ALIAS_LINE}`;\n }\n\n return `Alias added to ${rcFile}. Run:\\n source ${rcFile}`;\n}\n","import { existsSync, mkdirSync, readdirSync, cpSync, rmSync, lstatSync } from 'fs';\nimport { join, basename } from 'path';\nimport { BACKUPS_DIR } from './paths.js';\n\nexport interface BackupInfo {\n timestamp: string;\n path: string;\n targets: string[];\n}\n\nexport function createBackupTimestamp(): string {\n return new Date().toISOString().replace(/[:.]/g, '-');\n}\n\nexport function createBackup(sourceDirs: string[]): BackupInfo {\n const timestamp = createBackupTimestamp();\n const backupPath = join(BACKUPS_DIR, timestamp);\n\n mkdirSync(backupPath, { recursive: true });\n\n const targets: string[] = [];\n\n for (const sourceDir of sourceDirs) {\n if (!existsSync(sourceDir)) continue;\n\n const targetName = basename(sourceDir);\n const targetPath = join(backupPath, targetName);\n\n // Use filter to skip symlinks — sync targets (e.g. ~/.claude/skills/)\n // contain symlinks back into ~/.panopticon/skills/ which causes cpSync\n // to fail with \"cannot copy to a subdirectory of self\".\n cpSync(sourceDir, targetPath, {\n recursive: true,\n filter: (src) => !lstatSync(src).isSymbolicLink(),\n });\n targets.push(targetName);\n }\n\n return {\n timestamp,\n path: backupPath,\n targets,\n };\n}\n\nexport function listBackups(): BackupInfo[] {\n if (!existsSync(BACKUPS_DIR)) return [];\n\n const entries = readdirSync(BACKUPS_DIR, { withFileTypes: true });\n\n return entries\n .filter((e) => e.isDirectory())\n .map((e) => {\n const backupPath = join(BACKUPS_DIR, e.name);\n const contents = readdirSync(backupPath);\n\n return {\n timestamp: e.name,\n path: backupPath,\n targets: contents,\n };\n })\n .sort((a, b) => b.timestamp.localeCompare(a.timestamp));\n}\n\nexport function restoreBackup(timestamp: string, targetDirs: Record<string, string>): void {\n const backupPath = join(BACKUPS_DIR, timestamp);\n\n if (!existsSync(backupPath)) {\n throw new Error(`Backup not found: ${timestamp}`);\n }\n\n const contents = readdirSync(backupPath, { withFileTypes: true });\n\n for (const entry of contents) {\n if (!entry.isDirectory()) continue;\n\n const sourcePath = join(backupPath, entry.name);\n const targetPath = targetDirs[entry.name];\n\n if (!targetPath) continue;\n\n // Remove existing and restore from backup\n if (existsSync(targetPath)) {\n rmSync(targetPath, { recursive: true });\n }\n\n cpSync(sourcePath, targetPath, { recursive: true });\n }\n}\n\nexport function cleanOldBackups(keepCount: number = 10): number {\n const backups = listBackups();\n\n if (backups.length <= keepCount) return 0;\n\n const toRemove = backups.slice(keepCount);\n let removed = 0;\n\n for (const backup of toRemove) {\n rmSync(backup.path, { recursive: true });\n removed++;\n }\n\n return removed;\n}\n","import { existsSync, mkdirSync, readdirSync, symlinkSync, unlinkSync, lstatSync, readlinkSync, rmSync, copyFileSync, chmodSync } from 'fs';\nimport { join, basename } from 'path';\nimport { SKILLS_DIR, COMMANDS_DIR, AGENTS_DIR, BIN_DIR, SOURCE_SCRIPTS_DIR, SOURCE_DEV_SKILLS_DIR, SYNC_TARGETS, isDevMode, type Runtime } from './paths.js';\n\nexport interface SyncItem {\n name: string;\n sourcePath: string;\n targetPath: string;\n status: 'new' | 'exists' | 'conflict' | 'symlink';\n}\n\nexport interface SyncPlan {\n runtime: Runtime;\n skills: SyncItem[];\n commands: SyncItem[];\n agents: SyncItem[];\n devSkills: SyncItem[]; // Developer-only skills (only synced in dev mode)\n}\n\n/**\n * Remove a file, symlink, or directory safely\n */\nfunction removeTarget(targetPath: string): void {\n const stats = lstatSync(targetPath);\n if (stats.isDirectory() && !stats.isSymbolicLink()) {\n // It's a real directory, remove recursively\n rmSync(targetPath, { recursive: true, force: true });\n } else {\n // It's a file or symlink\n unlinkSync(targetPath);\n }\n}\n\n/**\n * Check if a path is a Panopticon-managed symlink\n */\nexport function isPanopticonSymlink(targetPath: string): boolean {\n if (!existsSync(targetPath)) return false;\n\n try {\n const stats = lstatSync(targetPath);\n if (!stats.isSymbolicLink()) return false;\n\n const linkTarget = readlinkSync(targetPath);\n // It's ours if it points to our skills/commands dir\n return linkTarget.includes('.panopticon');\n } catch {\n return false;\n }\n}\n\n/**\n * Plan what would be synced (dry run)\n */\nexport function planSync(runtime: Runtime): SyncPlan {\n const targets = SYNC_TARGETS[runtime];\n if (!targets) {\n throw new Error(`Unknown sync target \"${runtime}\". Valid targets: ${Object.keys(SYNC_TARGETS).join(', ')}`);\n }\n const plan: SyncPlan = {\n runtime,\n skills: [],\n commands: [],\n agents: [],\n devSkills: [],\n };\n\n // Plan skills sync\n if (existsSync(SKILLS_DIR)) {\n const skills = readdirSync(SKILLS_DIR, { withFileTypes: true })\n .filter((d) => d.isDirectory());\n\n for (const skill of skills) {\n const sourcePath = join(SKILLS_DIR, skill.name);\n const targetPath = join(targets.skills, skill.name);\n\n let status: SyncItem['status'] = 'new';\n\n if (existsSync(targetPath)) {\n if (isPanopticonSymlink(targetPath)) {\n status = 'symlink'; // Already managed by us\n } else {\n status = 'conflict'; // User content exists\n }\n }\n\n plan.skills.push({ name: skill.name, sourcePath, targetPath, status });\n }\n }\n\n // Plan dev-skills sync (only in dev mode)\n if (isDevMode() && existsSync(SOURCE_DEV_SKILLS_DIR)) {\n const devSkills = readdirSync(SOURCE_DEV_SKILLS_DIR, { withFileTypes: true })\n .filter((d) => d.isDirectory());\n\n for (const skill of devSkills) {\n const sourcePath = join(SOURCE_DEV_SKILLS_DIR, skill.name);\n const targetPath = join(targets.skills, skill.name);\n\n let status: SyncItem['status'] = 'new';\n\n if (existsSync(targetPath)) {\n if (isPanopticonSymlink(targetPath)) {\n status = 'symlink'; // Already managed by us\n } else {\n status = 'conflict'; // User content exists\n }\n }\n\n plan.devSkills.push({ name: skill.name, sourcePath, targetPath, status });\n }\n }\n\n // Plan commands sync\n if (existsSync(COMMANDS_DIR)) {\n const commands = readdirSync(COMMANDS_DIR, { withFileTypes: true })\n .filter((d) => d.isDirectory());\n\n for (const cmd of commands) {\n const sourcePath = join(COMMANDS_DIR, cmd.name);\n const targetPath = join(targets.commands, cmd.name);\n\n let status: SyncItem['status'] = 'new';\n\n if (existsSync(targetPath)) {\n if (isPanopticonSymlink(targetPath)) {\n status = 'symlink';\n } else {\n status = 'conflict';\n }\n }\n\n plan.commands.push({ name: cmd.name, sourcePath, targetPath, status });\n }\n }\n\n // Plan agents sync\n if (existsSync(AGENTS_DIR)) {\n const agents = readdirSync(AGENTS_DIR, { withFileTypes: true })\n .filter((entry) => entry.isFile() && entry.name.endsWith('.md'));\n\n for (const agent of agents) {\n const sourcePath = join(AGENTS_DIR, agent.name);\n const targetPath = join(targets.agents, agent.name);\n\n let status: SyncItem['status'] = 'new';\n\n if (existsSync(targetPath)) {\n if (isPanopticonSymlink(targetPath)) {\n status = 'symlink'; // Already managed by us\n } else {\n status = 'conflict'; // User content exists\n }\n }\n\n plan.agents.push({ name: agent.name, sourcePath, targetPath, status });\n }\n }\n\n return plan;\n}\n\nexport interface SyncOptions {\n force?: boolean;\n dryRun?: boolean;\n}\n\nexport interface SyncResult {\n created: string[];\n skipped: string[];\n conflicts: string[];\n}\n\n/**\n * Execute sync for a runtime\n */\nexport function executeSync(runtime: Runtime, options: SyncOptions = {}): SyncResult {\n const targets = SYNC_TARGETS[runtime];\n if (!targets) {\n throw new Error(`Unknown sync target \"${runtime}\". Valid targets: ${Object.keys(SYNC_TARGETS).join(', ')}`);\n }\n const plan = planSync(runtime);\n const result: SyncResult = {\n created: [],\n skipped: [],\n conflicts: [],\n };\n\n // Ensure target directories exist\n mkdirSync(targets.skills, { recursive: true });\n mkdirSync(targets.commands, { recursive: true });\n mkdirSync(targets.agents, { recursive: true });\n\n // Process skills\n for (const item of plan.skills) {\n if (options.dryRun) {\n if (item.status === 'new' || item.status === 'symlink') {\n result.created.push(item.name);\n } else {\n result.conflicts.push(item.name);\n }\n continue;\n }\n\n if (item.status === 'conflict' && !options.force) {\n result.conflicts.push(item.name);\n continue;\n }\n\n // Remove existing if force or if it's our symlink\n if (existsSync(item.targetPath)) {\n removeTarget(item.targetPath);\n }\n\n // Create symlink\n symlinkSync(item.sourcePath, item.targetPath);\n result.created.push(item.name);\n }\n\n // Process commands\n for (const item of plan.commands) {\n if (options.dryRun) {\n if (item.status === 'new' || item.status === 'symlink') {\n result.created.push(item.name);\n } else {\n result.conflicts.push(item.name);\n }\n continue;\n }\n\n if (item.status === 'conflict' && !options.force) {\n result.conflicts.push(item.name);\n continue;\n }\n\n if (existsSync(item.targetPath)) {\n removeTarget(item.targetPath);\n }\n\n symlinkSync(item.sourcePath, item.targetPath);\n result.created.push(item.name);\n }\n\n // Process agents\n for (const item of plan.agents) {\n if (options.dryRun) {\n if (item.status === 'new' || item.status === 'symlink') {\n result.created.push(item.name);\n } else {\n result.conflicts.push(item.name);\n }\n continue;\n }\n\n if (item.status === 'conflict' && !options.force) {\n result.conflicts.push(item.name);\n continue;\n }\n\n if (existsSync(item.targetPath)) {\n removeTarget(item.targetPath);\n }\n\n symlinkSync(item.sourcePath, item.targetPath);\n result.created.push(item.name);\n }\n\n // Process dev-skills (only in dev mode)\n for (const item of plan.devSkills) {\n if (options.dryRun) {\n if (item.status === 'new' || item.status === 'symlink') {\n result.created.push(`${item.name} (dev)`);\n } else {\n result.conflicts.push(`${item.name} (dev)`);\n }\n continue;\n }\n\n if (item.status === 'conflict' && !options.force) {\n result.conflicts.push(`${item.name} (dev)`);\n continue;\n }\n\n if (existsSync(item.targetPath)) {\n removeTarget(item.targetPath);\n }\n\n symlinkSync(item.sourcePath, item.targetPath);\n result.created.push(`${item.name} (dev)`);\n }\n\n return result;\n}\n\n/**\n * Hook item for sync planning\n */\nexport interface HookItem {\n name: string;\n sourcePath: string;\n targetPath: string;\n status: 'new' | 'updated' | 'current';\n}\n\n/**\n * Plan hooks sync (checks what would be updated)\n */\nexport function planHooksSync(): HookItem[] {\n const hooks: HookItem[] = [];\n\n if (!existsSync(SOURCE_SCRIPTS_DIR)) {\n return hooks;\n }\n\n // Sync hook scripts (no extension) and bundled JS scripts (.js)\n // Skip source files (.ts), shell helpers (.sh), and other non-hook files (.mjs)\n const scripts = readdirSync(SOURCE_SCRIPTS_DIR, { withFileTypes: true })\n .filter((entry) => entry.isFile() && !entry.name.startsWith('.')\n && (!entry.name.includes('.') || entry.name.endsWith('.js')));\n\n for (const script of scripts) {\n const sourcePath = join(SOURCE_SCRIPTS_DIR, script.name);\n const targetPath = join(BIN_DIR, script.name);\n\n let status: HookItem['status'] = 'new';\n\n if (existsSync(targetPath)) {\n // Could compare file contents/timestamps here for 'current' vs 'updated'\n // For now, always update to ensure latest version\n status = 'updated';\n }\n\n hooks.push({ name: script.name, sourcePath, targetPath, status });\n }\n\n return hooks;\n}\n\n/**\n * Sync hooks (copy scripts to ~/.panopticon/bin/)\n */\nexport function syncHooks(): { synced: string[]; errors: string[] } {\n const result = { synced: [] as string[], errors: [] as string[] };\n\n // Ensure bin directory exists\n mkdirSync(BIN_DIR, { recursive: true });\n\n const hooks = planHooksSync();\n\n for (const hook of hooks) {\n try {\n copyFileSync(hook.sourcePath, hook.targetPath);\n chmodSync(hook.targetPath, 0o755); // Make executable\n result.synced.push(hook.name);\n } catch (error) {\n result.errors.push(`${hook.name}: ${error}`);\n }\n }\n\n return result;\n}\n","/**\n * Cross-Tracker Linking\n *\n * Manages links between issues in different trackers.\n * Links are stored in a local JSON file for persistence.\n */\n\nimport { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport type { TrackerType } from './interface.js';\n\n// Link direction types\nexport type LinkDirection = 'blocks' | 'blocked_by' | 'related' | 'duplicate_of';\n\n// A single link between two issues\nexport interface TrackerLink {\n sourceIssueRef: string; // e.g., \"MIN-630\"\n sourceTracker: TrackerType;\n targetIssueRef: string; // e.g., \"#42\"\n targetTracker: TrackerType;\n direction: LinkDirection;\n createdAt: string; // ISO timestamp\n}\n\n// Storage format\ninterface LinkStore {\n version: 1;\n links: TrackerLink[];\n}\n\n/**\n * Parse an issue reference to extract tracker and ID\n * Examples:\n * \"#42\" -> { tracker: \"github\", ref: \"#42\" }\n * \"github#42\" -> { tracker: \"github\", ref: \"#42\" }\n * \"MIN-630\" -> { tracker: \"linear\", ref: \"MIN-630\" }\n * \"gitlab#15\" -> { tracker: \"gitlab\", ref: \"#15\" }\n */\nexport function parseIssueRef(ref: string): { tracker: TrackerType; ref: string } | null {\n // Explicit tracker prefix\n if (ref.startsWith('github#')) {\n return { tracker: 'github', ref: `#${ref.slice(7)}` };\n }\n if (ref.startsWith('gitlab#')) {\n return { tracker: 'gitlab', ref: `#${ref.slice(7)}` };\n }\n if (ref.startsWith('linear:')) {\n return { tracker: 'linear', ref: ref.slice(7) };\n }\n\n // GitHub-style refs (#number)\n if (/^#\\d+$/.test(ref)) {\n return { tracker: 'github', ref };\n }\n\n // Linear-style refs (XXX-123)\n if (/^[A-Z]+-\\d+$/i.test(ref)) {\n return { tracker: 'linear', ref: ref.toUpperCase() };\n }\n\n return null;\n}\n\n/**\n * Format an issue ref with tracker prefix for display\n */\nexport function formatIssueRef(ref: string, tracker: TrackerType): string {\n if (tracker === 'github') {\n return ref.startsWith('#') ? `github${ref}` : `github#${ref}`;\n }\n if (tracker === 'gitlab') {\n return ref.startsWith('#') ? `gitlab${ref}` : `gitlab#${ref}`;\n }\n return ref; // Linear refs are already unique\n}\n\n/**\n * Link Manager for cross-tracker issue linking\n */\nexport class LinkManager {\n private storePath: string;\n private store: LinkStore;\n\n constructor(storePath?: string) {\n this.storePath = storePath ?? join(homedir(), '.panopticon', 'links.json');\n this.store = this.load();\n }\n\n private load(): LinkStore {\n if (existsSync(this.storePath)) {\n try {\n const data = JSON.parse(readFileSync(this.storePath, 'utf-8'));\n if (data.version === 1) {\n return data;\n }\n } catch {\n // Fall through to default\n }\n }\n return { version: 1, links: [] };\n }\n\n private save(): void {\n const dir = join(this.storePath, '..');\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n writeFileSync(this.storePath, JSON.stringify(this.store, null, 2));\n }\n\n /**\n * Add a link between two issues\n */\n addLink(\n source: { ref: string; tracker: TrackerType },\n target: { ref: string; tracker: TrackerType },\n direction: LinkDirection = 'related'\n ): TrackerLink {\n // Check if link already exists\n const existing = this.store.links.find(\n (l) =>\n l.sourceIssueRef === source.ref &&\n l.sourceTracker === source.tracker &&\n l.targetIssueRef === target.ref &&\n l.targetTracker === target.tracker\n );\n\n if (existing) {\n // Update direction if different\n if (existing.direction !== direction) {\n existing.direction = direction;\n this.save();\n }\n return existing;\n }\n\n const link: TrackerLink = {\n sourceIssueRef: source.ref,\n sourceTracker: source.tracker,\n targetIssueRef: target.ref,\n targetTracker: target.tracker,\n direction,\n createdAt: new Date().toISOString(),\n };\n\n this.store.links.push(link);\n this.save();\n return link;\n }\n\n /**\n * Remove a link between two issues\n */\n removeLink(\n source: { ref: string; tracker: TrackerType },\n target: { ref: string; tracker: TrackerType }\n ): boolean {\n const index = this.store.links.findIndex(\n (l) =>\n l.sourceIssueRef === source.ref &&\n l.sourceTracker === source.tracker &&\n l.targetIssueRef === target.ref &&\n l.targetTracker === target.tracker\n );\n\n if (index >= 0) {\n this.store.links.splice(index, 1);\n this.save();\n return true;\n }\n return false;\n }\n\n /**\n * Get all issues linked to a given issue\n */\n getLinkedIssues(ref: string, tracker: TrackerType): TrackerLink[] {\n return this.store.links.filter(\n (l) =>\n (l.sourceIssueRef === ref && l.sourceTracker === tracker) ||\n (l.targetIssueRef === ref && l.targetTracker === tracker)\n );\n }\n\n /**\n * Get all links (for debugging/admin)\n */\n getAllLinks(): TrackerLink[] {\n return [...this.store.links];\n }\n\n /**\n * Find linked issue in another tracker\n */\n findLinkedIssue(\n ref: string,\n sourceTracker: TrackerType,\n targetTracker: TrackerType\n ): string | null {\n // Check as source\n const asSource = this.store.links.find(\n (l) =>\n l.sourceIssueRef === ref &&\n l.sourceTracker === sourceTracker &&\n l.targetTracker === targetTracker\n );\n if (asSource) return asSource.targetIssueRef;\n\n // Check as target\n const asTarget = this.store.links.find(\n (l) =>\n l.targetIssueRef === ref &&\n l.targetTracker === sourceTracker &&\n l.sourceTracker === targetTracker\n );\n if (asTarget) return asTarget.sourceIssueRef;\n\n return null;\n }\n\n /**\n * Clear all links (for testing)\n */\n clear(): void {\n this.store.links = [];\n this.save();\n }\n}\n\n// Singleton instance\nlet _linkManager: LinkManager | null = null;\n\nexport function getLinkManager(): LinkManager {\n if (!_linkManager) {\n _linkManager = new LinkManager();\n }\n return _linkManager;\n}\n","/**\n * Issue Tracker Module\n *\n * Provides a unified interface for different issue tracking systems.\n */\n\n// Core interface and types\nexport type {\n IssueTracker,\n Issue,\n IssueFilters,\n IssueState,\n IssueUpdate,\n NewIssue,\n Comment,\n TrackerType,\n} from './interface.js';\n\nexport {\n NotImplementedError,\n IssueNotFoundError,\n TrackerAuthError,\n} from './interface.js';\n\n// Tracker implementations\nexport { LinearTracker } from './linear.js';\nexport { GitHubTracker } from './github.js';\nexport { GitLabTracker } from './gitlab.js';\n\n// Factory functions\nexport type { TrackerConfig } from './factory.js';\nexport {\n createTracker,\n createTrackerFromConfig,\n getPrimaryTracker,\n getSecondaryTracker,\n getAllTrackers,\n} from './factory.js';\n\n// Cross-tracker linking\nexport type { TrackerLink, LinkDirection } from './linking.js';\nexport {\n LinkManager,\n getLinkManager,\n parseIssueRef,\n formatIssueRef,\n} from './linking.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,YAAY,cAAc,sBAAsB;AACzD,SAAS,eAAe;AACxB,SAAS,YAAY;AAId,SAAS,cAAqB;AACnC,QAAM,QAAQ,QAAQ,IAAI,SAAS;AAEnC,MAAI,MAAM,SAAS,KAAK,EAAG,QAAO;AAClC,MAAI,MAAM,SAAS,MAAM,EAAG,QAAO;AACnC,MAAI,MAAM,SAAS,MAAM,EAAG,QAAO;AAEnC,SAAO;AACT;AAEO,SAAS,eAAe,OAA6B;AAC1D,QAAM,OAAO,QAAQ;AAErB,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,aAAO,KAAK,MAAM,QAAQ;AAAA,IAC5B,KAAK;AAEH,YAAM,SAAS,KAAK,MAAM,SAAS;AACnC,UAAI,WAAW,MAAM,EAAG,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AkB,iBACpB,EAAE,kBAAkB;AAAA,IACxB;AACA,QAAI,SAAU,QAAO,SAAS;AAG9B,UAAM,WAAW,KAAK,MAAM,MAAM;AAAA,MAChC,CAAC,MACC,EAAE,mBAAmB,OACrB,EAAE,kBAAkB,iBACpB,EAAE,kBAAkB;AAAA,IACxB;AACA,QAAI,SAAU,QAAO,SAAS;AAE9B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,QAAc;AACZ,SAAK,MAAM,QAAQ,CAAC;AACpB,SAAK,KAAK;AAAA,EACZ;AACF;AAGA,IAAI,eAAmC;AAEhC,SAAS,iBAA8B;AAC5C,MAAI,CAAC,cAAc;AACjB,mBAAe,IAAI,YAAY;AAAA,EACjC;AACA,SAAO;AACT;;;AC9OA;AAkBA;AAOA;AACA;AACA;AAIA;","names":["existsSync","join","existsSync","mkdirSync","readdirSync","lstatSync","rmSync","join","readFileSync","existsSync","mkdirSync","join","homedir"]}
|