promptlike 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/commands/export.js +32 -4
- package/dist/commands/rename.js +0 -1
- package/dist/lib/obsidianExport.js +167 -0
- package/dist/program.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.15.0 — 2026-11-30
|
|
4
|
+
|
|
5
|
+
- **New: `ple export --format obsidian`** writes your prompts as linked Obsidian notes, so Obsidian's graph view draws your prompt
|
|
6
|
+
chains. `ple export --project <repo> --format obsidian --out <folder>` creates `<folder>/<repo>-obsidian/`: one note per prompt, the
|
|
7
|
+
prompts it suggests next as `[[links]]` under **Next**, and each context type it needs as a link to a `context/<type>` hub note,
|
|
8
|
+
plus one map note for the repo. Only the type and name of a context slot are written, never its hint or a value. Open the folder
|
|
9
|
+
in Obsidian or copy it into your vault; `--force` overwrites an earlier export (never through a symbolic link). `--zip` is refused
|
|
10
|
+
for this format.
|
|
11
|
+
|
|
3
12
|
## 0.14.0 — 2026-11-27
|
|
4
13
|
|
|
5
14
|
- **New: `ple fork <id|ple:user/repo/prompt> [--project <repo>] [--title <t>] [--json]`** copies a public prompt of someone else into a repo you own (the web's Fork button). The copy starts private and keeps its source and license. Forking twice is reported, not an error; your own prompts, private prompts, repos you do not own and a plan limit are refused with a plain message.
|
package/dist/commands/export.js
CHANGED
|
@@ -45,14 +45,16 @@ const folder_1 = require("../lib/folder");
|
|
|
45
45
|
const promptList_1 = require("../lib/promptList");
|
|
46
46
|
const fsSafe_1 = require("../lib/fsSafe");
|
|
47
47
|
const agentExport_1 = require("../lib/agentExport");
|
|
48
|
+
const obsidianExport_1 = require("../lib/obsidianExport");
|
|
48
49
|
/** Hard cap for a repo export — 10 pages × 100. */
|
|
49
50
|
const MAX_PAGES = 10;
|
|
50
51
|
const PAGE_SIZE = 100;
|
|
52
|
+
const EXPORT_FORMATS = [...agentExport_1.AGENT_EXPORT_FORMATS, 'obsidian'];
|
|
51
53
|
function parseFormat(value) {
|
|
52
54
|
const v = (value ?? '').trim().toLowerCase();
|
|
53
|
-
if (
|
|
55
|
+
if (EXPORT_FORMATS.includes(v))
|
|
54
56
|
return v;
|
|
55
|
-
throw new Error(`--format must be one of: ${
|
|
57
|
+
throw new Error(`--format must be one of: ${EXPORT_FORMATS.join(', ')}.`);
|
|
56
58
|
}
|
|
57
59
|
function fromRemote(p) {
|
|
58
60
|
const v = (0, promptResolver_1.fetchPromptContent)(p);
|
|
@@ -61,12 +63,12 @@ function fromRemote(p) {
|
|
|
61
63
|
: '';
|
|
62
64
|
if (!body.trim())
|
|
63
65
|
return null;
|
|
64
|
-
return { title: p.title, description: p.description ?? null, body, projectName: p.project_name ?? null };
|
|
66
|
+
return { id: p.id, title: p.title, description: p.description ?? null, body, projectName: p.project_name ?? null };
|
|
65
67
|
}
|
|
66
68
|
function fromLocal(p) {
|
|
67
69
|
if (!p.body.trim())
|
|
68
70
|
return null;
|
|
69
|
-
return { title: p.title, description: p.description || null, body: p.body.trim() };
|
|
71
|
+
return { id: p.slug, title: p.title, description: p.description || null, body: p.body.trim() };
|
|
70
72
|
}
|
|
71
73
|
async function collectRemoteRepo(projectId, folder) {
|
|
72
74
|
const out = [];
|
|
@@ -119,6 +121,22 @@ function writeSkill(skill, options) {
|
|
|
119
121
|
}
|
|
120
122
|
return folder;
|
|
121
123
|
}
|
|
124
|
+
/** obsidian: `<out>/<repo>-obsidian/` içine notlar (kasanın içine kopyalanır ya da kasa olarak açılır). */
|
|
125
|
+
function writeObsidian(name, files, options) {
|
|
126
|
+
const parent = path.resolve(options.out ?? '.');
|
|
127
|
+
fs.mkdirSync(parent, { recursive: true });
|
|
128
|
+
const folder = path.join(parent, `${(0, obsidianExport_1.noteName)(name, 'prompts')}-obsidian`);
|
|
129
|
+
assertInside(parent, folder);
|
|
130
|
+
ensureWritable(folder, options.force);
|
|
131
|
+
for (const f of files) {
|
|
132
|
+
const target = path.join(folder, ...f.path.split('/'));
|
|
133
|
+
assertInside(folder, target);
|
|
134
|
+
(0, fsSafe_1.assertNotSymlink)(target);
|
|
135
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
136
|
+
fs.writeFileSync(target, f.content, 'utf-8');
|
|
137
|
+
}
|
|
138
|
+
return folder;
|
|
139
|
+
}
|
|
122
140
|
function writeAgentsMd(text, options) {
|
|
123
141
|
if (!options.out) {
|
|
124
142
|
process.stdout.write(text);
|
|
@@ -202,6 +220,16 @@ async function exportCommand(name, options = {}) {
|
|
|
202
220
|
throw new Error('Give a prompt name, or --project <repo> to export a whole repo.');
|
|
203
221
|
}
|
|
204
222
|
}
|
|
223
|
+
if (format === 'obsidian') {
|
|
224
|
+
const name = repo ? repo.name : (single?.projectName ?? 'prompts');
|
|
225
|
+
const prompts = repo ? repo.prompts : single ? [single] : [];
|
|
226
|
+
if (prompts.length === 0) {
|
|
227
|
+
throw new Error(folder !== undefined ? `Nothing to export — no prompts with content in folder '${folder || '(root)'}'.` : 'Nothing to export — no prompts with content.');
|
|
228
|
+
}
|
|
229
|
+
const written = writeObsidian(name, (0, obsidianExport_1.buildObsidianVault)(name, prompts, exportedAt), options);
|
|
230
|
+
console.error(format_1.c.success(`✓ Exported ${prompts.length} prompt${prompts.length === 1 ? '' : 's'} as Obsidian notes → ${written}`));
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
205
233
|
let text = null;
|
|
206
234
|
let skill = null;
|
|
207
235
|
let count = 1;
|
package/dist/commands/rename.js
CHANGED
|
@@ -18,7 +18,6 @@ const local_1 = require("./local");
|
|
|
18
18
|
const MAX_TITLE = 200;
|
|
19
19
|
/** One line: control characters and line breaks collapse to spaces, like the title `ple save` stores. */
|
|
20
20
|
function cleanNewTitle(raw) {
|
|
21
|
-
// eslint-disable-next-line no-control-regex
|
|
22
21
|
return raw.replace(/[\u0000-\u001f\u007f]+/g, ' ').replace(/\s{2,}/g, ' ').trim();
|
|
23
22
|
}
|
|
24
23
|
async function renameCommand(name, newTitle, options = {}) {
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readGraphLite = readGraphLite;
|
|
4
|
+
exports.noteName = noteName;
|
|
5
|
+
exports.buildObsidianVault = buildObsidianVault;
|
|
6
|
+
const OPEN = '<!-- ple-graph';
|
|
7
|
+
function cleanLine(v, max) {
|
|
8
|
+
if (typeof v !== 'string')
|
|
9
|
+
return null;
|
|
10
|
+
const s = v.replace(/[\u0000-\u001f\u007f]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
11
|
+
return s ? s.slice(0, max) : null;
|
|
12
|
+
}
|
|
13
|
+
/** Çitli kod bloklarının (``` / ~~~) dışında kalan ilk kapalı bloğun aralığı. */
|
|
14
|
+
function findBlock(body) {
|
|
15
|
+
let inFence = false;
|
|
16
|
+
let offset = 0;
|
|
17
|
+
for (const line of body.split('\n')) {
|
|
18
|
+
if (/^\s*(```|~~~)/.test(line))
|
|
19
|
+
inFence = !inFence;
|
|
20
|
+
if (!inFence) {
|
|
21
|
+
const i = line.indexOf(OPEN);
|
|
22
|
+
if (i >= 0) {
|
|
23
|
+
const start = offset + i;
|
|
24
|
+
const close = body.indexOf('-->', start + OPEN.length);
|
|
25
|
+
if (close < 0)
|
|
26
|
+
return null; // kapanmamış: kullanıcının metni, dokunma
|
|
27
|
+
const json = body.slice(start + OPEN.length, close).trim();
|
|
28
|
+
return { start, end: close + 3, json };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
offset += line.length + 1;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/** Gövdeden bloğu çıkarır ve okur. Blok yoksa ya da bozuksa `graph` null, gövde (blok varsa çıkarılmış) döner. */
|
|
36
|
+
function readGraphLite(body) {
|
|
37
|
+
const b = findBlock(body);
|
|
38
|
+
if (!b)
|
|
39
|
+
return { body, graph: null };
|
|
40
|
+
const stripped = (body.slice(0, b.start) + body.slice(b.end)).replace(/\n{3,}/g, '\n\n').trim();
|
|
41
|
+
let raw;
|
|
42
|
+
try {
|
|
43
|
+
raw = JSON.parse(b.json);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return { body: stripped, graph: null };
|
|
47
|
+
}
|
|
48
|
+
if (!raw || typeof raw !== 'object' || raw.v !== 1)
|
|
49
|
+
return { body: stripped, graph: null };
|
|
50
|
+
const r = raw;
|
|
51
|
+
const needs = [];
|
|
52
|
+
for (const n of Array.isArray(r.needs) ? r.needs.slice(0, 12) : []) {
|
|
53
|
+
const name = cleanLine(n?.name, 64);
|
|
54
|
+
const type = cleanLine(n?.type, 48);
|
|
55
|
+
if (name)
|
|
56
|
+
needs.push({ name, type: type ?? name });
|
|
57
|
+
}
|
|
58
|
+
const next = [];
|
|
59
|
+
for (const e of Array.isArray(r.next) ? r.next.slice(0, 8) : []) {
|
|
60
|
+
const prompt = cleanLine(e?.prompt, 100);
|
|
61
|
+
const label = cleanLine(e?.label, 80);
|
|
62
|
+
if (prompt)
|
|
63
|
+
next.push(label ? { prompt, label } : { prompt });
|
|
64
|
+
}
|
|
65
|
+
return { body: stripped, graph: { needs, next } };
|
|
66
|
+
}
|
|
67
|
+
/** Obsidian dosya adı: wikilink'i bozan karakterler (`[]#^|`) ve yol ayırıcıları çıkar. */
|
|
68
|
+
function noteName(title, fallback = 'prompt') {
|
|
69
|
+
const s = title
|
|
70
|
+
.replace(/[\\/:*?"<>|#^[\]]/g, '-')
|
|
71
|
+
.replace(/\s+/g, ' ')
|
|
72
|
+
.replace(/^[.\s-]+|[.\s-]+$/g, '')
|
|
73
|
+
.slice(0, 100)
|
|
74
|
+
.trim();
|
|
75
|
+
return s || fallback;
|
|
76
|
+
}
|
|
77
|
+
function typeSlug(type) {
|
|
78
|
+
return noteName(type.toLowerCase().replace(/\s+/g, '-'), 'context');
|
|
79
|
+
}
|
|
80
|
+
function yamlString(v) {
|
|
81
|
+
return JSON.stringify(v); // JSON dizgesi geçerli YAML'dir
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Bir prompt kümesinden Obsidian notları üretir: prompt notları, `context/<tür>.md` merkezleri ve bir MOC.
|
|
85
|
+
* Kenar hedefi şunlarla eşleşir: tam id, 8+ haneli id öneki, başlık ya da başlığın slug'ı (büyük/küçük harf duyarsız).
|
|
86
|
+
*/
|
|
87
|
+
function buildObsidianVault(repoName, prompts, exportedAt) {
|
|
88
|
+
const used = new Set();
|
|
89
|
+
const notes = prompts.map((p) => {
|
|
90
|
+
let name = noteName(p.title);
|
|
91
|
+
let n = 2;
|
|
92
|
+
while (used.has(name.toLowerCase()))
|
|
93
|
+
name = `${noteName(p.title)} (${n++})`;
|
|
94
|
+
used.add(name.toLowerCase());
|
|
95
|
+
return { p, name, ...readGraphLite(p.body) };
|
|
96
|
+
});
|
|
97
|
+
const slug = (s) => s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, '-').replace(/^-+|-+$/g, '');
|
|
98
|
+
const resolve = (target) => {
|
|
99
|
+
const t = target.toLowerCase();
|
|
100
|
+
for (const x of notes) {
|
|
101
|
+
const id = (x.p.id ?? '').toLowerCase();
|
|
102
|
+
if (id && (id === t || (t.length >= 8 && id.startsWith(t))))
|
|
103
|
+
return x.name;
|
|
104
|
+
}
|
|
105
|
+
for (const x of notes)
|
|
106
|
+
if (x.p.title.toLowerCase() === t || slug(x.p.title) === slug(target))
|
|
107
|
+
return x.name;
|
|
108
|
+
return null;
|
|
109
|
+
};
|
|
110
|
+
const byType = new Map();
|
|
111
|
+
const files = [];
|
|
112
|
+
for (const x of notes) {
|
|
113
|
+
const g = x.graph;
|
|
114
|
+
const fm = [
|
|
115
|
+
'---',
|
|
116
|
+
'type: ple-prompt',
|
|
117
|
+
`title: ${yamlString(x.p.title)}`,
|
|
118
|
+
...(x.p.id ? [`ple_id: ${yamlString(x.p.id)}`] : []),
|
|
119
|
+
...(x.p.projectName ? [`project: ${yamlString(x.p.projectName)}`] : []),
|
|
120
|
+
...(x.p.version ? [`version: ${x.p.version}`] : []),
|
|
121
|
+
...(g && g.needs.length ? [`needs: [${g.needs.map((n) => yamlString(n.type)).join(', ')}]`] : []),
|
|
122
|
+
`exported_at: ${yamlString(exportedAt)}`,
|
|
123
|
+
'tags: [ple/prompt]',
|
|
124
|
+
'---',
|
|
125
|
+
];
|
|
126
|
+
const parts = [fm.join('\n'), `# ${x.p.title}`];
|
|
127
|
+
if (x.p.description)
|
|
128
|
+
parts.push(`> ${x.p.description.replace(/\n/g, ' ')}`);
|
|
129
|
+
parts.push(x.body);
|
|
130
|
+
if (g && g.next.length) {
|
|
131
|
+
const lines = g.next.map((e) => {
|
|
132
|
+
const hit = resolve(e.prompt);
|
|
133
|
+
const shown = e.label ? ` — ${e.label}` : '';
|
|
134
|
+
return hit ? `- [[${hit}]]${shown}` : `- \`${e.prompt}\` (not in this export)${shown}`;
|
|
135
|
+
});
|
|
136
|
+
parts.push(`## Next\n\n${lines.join('\n')}`);
|
|
137
|
+
}
|
|
138
|
+
if (g && g.needs.length) {
|
|
139
|
+
const lines = g.needs.map((nd) => {
|
|
140
|
+
const ts = typeSlug(nd.type);
|
|
141
|
+
const entry = byType.get(ts) ?? { type: nd.type, users: [] };
|
|
142
|
+
entry.users.push({ note: x.name, slot: nd.name });
|
|
143
|
+
byType.set(ts, entry);
|
|
144
|
+
return `- [[context/${ts}]] — \`{{${nd.name}}}\``;
|
|
145
|
+
});
|
|
146
|
+
parts.push(`## Needs\n\n${lines.join('\n')}`);
|
|
147
|
+
}
|
|
148
|
+
files.push({ path: `${x.name}.md`, content: parts.join('\n\n') + '\n' });
|
|
149
|
+
}
|
|
150
|
+
for (const [ts, e] of byType) {
|
|
151
|
+
const body = [
|
|
152
|
+
['---', 'type: ple-context-type', `context_type: ${yamlString(e.type)}`, 'tags: [ple/context]', '---'].join('\n'),
|
|
153
|
+
`# Context: ${e.type}`,
|
|
154
|
+
'Prompts that need this kind of context. Link your own notes here with ' +
|
|
155
|
+
`\`[[context/${ts}]]\` to connect them in the graph; PromptLikeEngineer never reads them.`,
|
|
156
|
+
e.users.map((u) => `- [[${u.note}]] — \`{{${u.slot}}}\``).join('\n'),
|
|
157
|
+
];
|
|
158
|
+
files.push({ path: `context/${ts}.md`, content: body.join('\n\n') + '\n' });
|
|
159
|
+
}
|
|
160
|
+
const moc = [
|
|
161
|
+
['---', 'type: ple-moc', `exported_at: ${yamlString(exportedAt)}`, 'tags: [ple/moc]', '---'].join('\n'),
|
|
162
|
+
`# ${repoName}`,
|
|
163
|
+
notes.map((x) => `- [[${x.name}]]`).join('\n'),
|
|
164
|
+
];
|
|
165
|
+
files.push({ path: `${noteName(repoName, 'prompts')} MOC.md`, content: moc.join('\n\n') + '\n' });
|
|
166
|
+
return files;
|
|
167
|
+
}
|
package/dist/program.js
CHANGED
|
@@ -383,9 +383,9 @@ function buildProgram() {
|
|
|
383
383
|
.action(runWithErrorHandler((source, opts) => (0, import_1.importCommand)({ ...opts, source })));
|
|
384
384
|
scope(program
|
|
385
385
|
.command('export [name]')
|
|
386
|
-
.description('Export a prompt (or a whole repo with --project) as an AGENTS.md section
|
|
387
|
-
.requiredOption('--format <format>', 'agents-md | skill')
|
|
388
|
-
.option('-o, --out <path>', 'agents-md: file to write (default stdout) · skill: parent folder (default .)')
|
|
386
|
+
.description('Export a prompt (or a whole repo with --project) as an AGENTS.md section, an Agent Skill (SKILL.md) or linked Obsidian notes')
|
|
387
|
+
.requiredOption('--format <format>', 'agents-md | skill | obsidian')
|
|
388
|
+
.option('-o, --out <path>', 'agents-md: file to write (default stdout) · skill, obsidian: parent folder (default .)')
|
|
389
389
|
.option('--folder <path>', 'With --project: export only this folder of the repo (and what is under it)')
|
|
390
390
|
.option('--zip', 'skill: write <name>.zip (upload in Claude) instead of a folder')
|
|
391
391
|
.option('-f, --force', 'Overwrite an existing file or folder (never through a symbolic link)')).action(runWithErrorHandler(export_1.exportCommand));
|
package/package.json
CHANGED