emdash-emit 0.1.25 → 0.1.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/CHANGELOG.md +154 -4
- package/dist/cli/commands/conflicts.d.ts.map +1 -1
- package/dist/cli/commands/conflicts.js +2 -22
- package/dist/cli/commands/conflicts.js.map +1 -1
- package/dist/cli/commands/delete.d.ts.map +1 -1
- package/dist/cli/commands/delete.js +1 -13
- package/dist/cli/commands/delete.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +1 -13
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/media.d.ts.map +1 -1
- package/dist/cli/commands/media.js +1 -13
- package/dist/cli/commands/media.js.map +1 -1
- package/dist/cli/commands/new.d.ts.map +1 -1
- package/dist/cli/commands/new.js +1 -13
- package/dist/cli/commands/new.js.map +1 -1
- package/dist/cli/commands/pull.d.ts +3 -3
- package/dist/cli/commands/pull.d.ts.map +1 -1
- package/dist/cli/commands/pull.js +142 -88
- package/dist/cli/commands/pull.js.map +1 -1
- package/dist/cli/commands/push.d.ts +1 -1
- package/dist/cli/commands/push.d.ts.map +1 -1
- package/dist/cli/commands/push.js +32 -90
- package/dist/cli/commands/push.js.map +1 -1
- package/dist/cli/context.d.ts +12 -0
- package/dist/cli/context.d.ts.map +1 -1
- package/dist/cli/context.js +27 -1
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/report-failure.d.ts +6 -0
- package/dist/cli/report-failure.d.ts.map +1 -0
- package/dist/cli/report-failure.js +71 -0
- package/dist/cli/report-failure.js.map +1 -0
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +1 -1
- package/dist/client/api.js.map +1 -1
- package/dist/client/lock.js.map +1 -1
- package/dist/client/mapper.js.map +1 -1
- package/dist/client/media.d.ts.map +1 -1
- package/dist/client/media.js.map +1 -1
- package/dist/db/baseline.d.ts +16 -1
- package/dist/db/baseline.d.ts.map +1 -1
- package/dist/db/baseline.js +25 -0
- package/dist/db/baseline.js.map +1 -1
- package/dist/db/cache.d.ts +2 -3
- package/dist/db/cache.d.ts.map +1 -1
- package/dist/db/cache.js +3 -295
- package/dist/db/cache.js.map +1 -1
- package/dist/db/migrations.d.ts +7 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +320 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/mcp/heartbeat.d.ts +1 -34
- package/dist/mcp/heartbeat.d.ts.map +1 -1
- package/dist/mcp/heartbeat.js +1 -113
- package/dist/mcp/heartbeat.js.map +1 -1
- package/dist/mcp/tool-errors.d.ts +12 -1
- package/dist/mcp/tool-errors.d.ts.map +1 -1
- package/dist/mcp/tool-errors.js +29 -0
- package/dist/mcp/tool-errors.js.map +1 -1
- package/dist/mcp/tools/sync-conflicts.d.ts.map +1 -1
- package/dist/mcp/tools/sync-conflicts.js +46 -58
- package/dist/mcp/tools/sync-conflicts.js.map +1 -1
- package/dist/mcp/tools/sync-delete.d.ts.map +1 -1
- package/dist/mcp/tools/sync-delete.js +18 -30
- package/dist/mcp/tools/sync-delete.js.map +1 -1
- package/dist/mcp/tools/sync-diff.d.ts.map +1 -1
- package/dist/mcp/tools/sync-diff.js +10 -31
- package/dist/mcp/tools/sync-diff.js.map +1 -1
- package/dist/mcp/tools/sync-doctor.d.ts.map +1 -1
- package/dist/mcp/tools/sync-doctor.js +18 -30
- package/dist/mcp/tools/sync-doctor.js.map +1 -1
- package/dist/mcp/tools/sync-media-search.d.ts.map +1 -1
- package/dist/mcp/tools/sync-media-search.js +40 -52
- package/dist/mcp/tools/sync-media-search.js.map +1 -1
- package/dist/mcp/tools/sync-new.d.ts.map +1 -1
- package/dist/mcp/tools/sync-new.js +34 -55
- package/dist/mcp/tools/sync-new.js.map +1 -1
- package/dist/mcp/tools/sync-pull.d.ts.map +1 -1
- package/dist/mcp/tools/sync-pull.js +202 -222
- package/dist/mcp/tools/sync-pull.js.map +1 -1
- package/dist/mcp/tools/sync-push.d.ts.map +1 -1
- package/dist/mcp/tools/sync-push.js +64 -84
- package/dist/mcp/tools/sync-push.js.map +1 -1
- package/dist/mcp/tools/sync-status.d.ts.map +1 -1
- package/dist/mcp/tools/sync-status.js +3 -13
- package/dist/mcp/tools/sync-status.js.map +1 -1
- package/dist/presentation/article_report.d.ts +5 -0
- package/dist/presentation/article_report.d.ts.map +1 -1
- package/dist/presentation/article_report.js +17 -0
- package/dist/presentation/article_report.js.map +1 -1
- package/dist/sync/baseline-reconstruction.d.ts +43 -0
- package/dist/sync/baseline-reconstruction.d.ts.map +1 -0
- package/dist/sync/baseline-reconstruction.js +103 -0
- package/dist/sync/baseline-reconstruction.js.map +1 -0
- package/dist/sync/bylines.d.ts +5 -0
- package/dist/sync/bylines.d.ts.map +1 -1
- package/dist/sync/bylines.js +29 -0
- package/dist/sync/bylines.js.map +1 -1
- package/dist/sync/conflicts.d.ts.map +1 -1
- package/dist/sync/conflicts.js +21 -4
- package/dist/sync/conflicts.js.map +1 -1
- package/dist/sync/delete.d.ts.map +1 -1
- package/dist/sync/delete.js +12 -1
- package/dist/sync/delete.js.map +1 -1
- package/dist/sync/diff.d.ts.map +1 -1
- package/dist/sync/diff.js +58 -27
- package/dist/sync/diff.js.map +1 -1
- package/dist/sync/doctor.d.ts.map +1 -1
- package/dist/sync/doctor.js +13 -3
- package/dist/sync/doctor.js.map +1 -1
- package/dist/sync/guards.d.ts +1 -1
- package/dist/sync/guards.d.ts.map +1 -1
- package/dist/sync/guards.js +2 -1
- package/dist/sync/guards.js.map +1 -1
- package/dist/sync/media/companions.d.ts.map +1 -1
- package/dist/sync/media/companions.js.map +1 -1
- package/dist/sync/media/naming_mirror.d.ts.map +1 -1
- package/dist/sync/media/naming_mirror.js +11 -2
- package/dist/sync/media/naming_mirror.js.map +1 -1
- package/dist/sync/media/pull_article.d.ts +2 -0
- package/dist/sync/media/pull_article.d.ts.map +1 -1
- package/dist/sync/media/pull_article.js +74 -25
- package/dist/sync/media/pull_article.js.map +1 -1
- package/dist/sync/media/pull_library.d.ts.map +1 -1
- package/dist/sync/media/pull_library.js +34 -61
- package/dist/sync/media/pull_library.js.map +1 -1
- package/dist/sync/media/remote_index.d.ts +16 -1
- package/dist/sync/media/remote_index.d.ts.map +1 -1
- package/dist/sync/media/remote_index.js +2 -2
- package/dist/sync/media/remote_index.js.map +1 -1
- package/dist/sync/merge.d.ts.map +1 -1
- package/dist/sync/merge.js +5 -5
- package/dist/sync/merge.js.map +1 -1
- package/dist/sync/new.d.ts.map +1 -1
- package/dist/sync/new.js +5 -4
- package/dist/sync/new.js.map +1 -1
- package/dist/sync/orchestrator.d.ts +39 -0
- package/dist/sync/orchestrator.d.ts.map +1 -1
- package/dist/sync/orchestrator.js +93 -80
- package/dist/sync/orchestrator.js.map +1 -1
- package/dist/sync/preflight/image_probe.d.ts +28 -0
- package/dist/sync/preflight/image_probe.d.ts.map +1 -0
- package/dist/sync/preflight/image_probe.js +70 -0
- package/dist/sync/preflight/image_probe.js.map +1 -0
- package/dist/sync/preflight.d.ts.map +1 -1
- package/dist/sync/preflight.js +48 -45
- package/dist/sync/preflight.js.map +1 -1
- package/dist/sync/pull/fast_path.d.ts +9 -0
- package/dist/sync/pull/fast_path.d.ts.map +1 -0
- package/dist/sync/pull/fast_path.js +383 -0
- package/dist/sync/pull/fast_path.js.map +1 -0
- package/dist/sync/pull/index.d.ts +15 -0
- package/dist/sync/pull/index.d.ts.map +1 -0
- package/dist/sync/pull/index.js +372 -0
- package/dist/sync/pull/index.js.map +1 -0
- package/dist/sync/pull/list.d.ts +22 -0
- package/dist/sync/pull/list.d.ts.map +1 -0
- package/dist/sync/pull/list.js +175 -0
- package/dist/sync/pull/list.js.map +1 -0
- package/dist/sync/pull/media_stage.d.ts +67 -0
- package/dist/sync/pull/media_stage.d.ts.map +1 -0
- package/dist/sync/pull/media_stage.js +599 -0
- package/dist/sync/pull/media_stage.js.map +1 -0
- package/dist/sync/pull/quarantine.d.ts +22 -0
- package/dist/sync/pull/quarantine.d.ts.map +1 -0
- package/dist/sync/pull/quarantine.js +174 -0
- package/dist/sync/pull/quarantine.js.map +1 -0
- package/dist/sync/pull/types.d.ts +135 -0
- package/dist/sync/pull/types.d.ts.map +1 -0
- package/dist/sync/pull/types.js +23 -0
- package/dist/sync/pull/types.js.map +1 -0
- package/dist/sync/pull.d.ts +1 -114
- package/dist/sync/pull.d.ts.map +1 -1
- package/dist/sync/pull.js +1 -861
- package/dist/sync/pull.js.map +1 -1
- package/dist/sync/push/commit.d.ts.map +1 -1
- package/dist/sync/push/commit.js +1 -2
- package/dist/sync/push/commit.js.map +1 -1
- package/dist/sync/push/index.d.ts.map +1 -1
- package/dist/sync/push/index.js +4 -3
- package/dist/sync/push/index.js.map +1 -1
- package/dist/sync/push/merge_stage.js +1 -1
- package/dist/sync/push/merge_stage.js.map +1 -1
- package/dist/sync/push/taxonomy_plan.d.ts +4 -0
- package/dist/sync/push/taxonomy_plan.d.ts.map +1 -1
- package/dist/sync/push/taxonomy_plan.js +22 -10
- package/dist/sync/push/taxonomy_plan.js.map +1 -1
- package/dist/sync/push/transport.d.ts +1 -1
- package/dist/sync/push/transport.d.ts.map +1 -1
- package/dist/sync/push/transport.js +1 -1
- package/dist/sync/push/transport.js.map +1 -1
- package/dist/sync/status.d.ts.map +1 -1
- package/dist/sync/status.js +11 -57
- package/dist/sync/status.js.map +1 -1
- package/dist/sync/taxonomies.d.ts +45 -0
- package/dist/sync/taxonomies.d.ts.map +1 -1
- package/dist/sync/taxonomies.js +258 -119
- package/dist/sync/taxonomies.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/mcp-heartbeat.d.ts +36 -0
- package/dist/utils/mcp-heartbeat.d.ts.map +1 -0
- package/dist/utils/mcp-heartbeat.js +126 -0
- package/dist/utils/mcp-heartbeat.js.map +1 -0
- package/dist/utils/media-body-refs.d.ts.map +1 -1
- package/dist/utils/media-body-refs.js +2 -2
- package/dist/utils/media-body-refs.js.map +1 -1
- package/dist/utils/taxonomy-key.d.ts +44 -0
- package/dist/utils/taxonomy-key.d.ts.map +1 -0
- package/dist/utils/taxonomy-key.js +63 -0
- package/dist/utils/taxonomy-key.js.map +1 -0
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { z } from 'zod';
|
|
23
23
|
import { listConflicts, diffConflict, resolveConflict, pruneConflicts, } from '../../sync/conflicts.js';
|
|
24
|
-
import { formatToolError, formatToolSuccess } from '../tool-errors.js';
|
|
24
|
+
import { formatToolError, formatToolSuccess, withResolvedContext } from '../tool-errors.js';
|
|
25
25
|
export function registerSyncConflictsTool(server, resolveContext) {
|
|
26
26
|
server.tool('sync_conflicts', 'Manage quarantined sync conflict copies (.conflict.md) and deletion rescue backups (.deleted.md) in posts/conflicts/. Actions: "list" (view quarantined files and types), "diff" (inspect line-by-line differences against canonical live article), "resolve" (strategy "accept-local" to restore/replace canonical article, or "accept-canonical" to discard quarantined copy), and "prune" (clean up eligible quarantined copies with safety checks).', {
|
|
27
27
|
action: z
|
|
@@ -56,68 +56,56 @@ export function registerSyncConflictsTool(server, resolveContext) {
|
|
|
56
56
|
.optional()
|
|
57
57
|
.describe('Collection containing conflicts (defaults to "posts")'),
|
|
58
58
|
profile: z.string().optional().describe('Target profile name for multi-site setups'),
|
|
59
|
-
}, async (args) => {
|
|
60
|
-
let ctx;
|
|
61
|
-
try {
|
|
62
|
-
ctx = resolveContext(args.profile);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
return formatToolError(error);
|
|
66
|
-
}
|
|
59
|
+
}, async (args) => withResolvedContext(resolveContext, args, (ctx) => {
|
|
67
60
|
const collection = args.collection || ctx.config.defaultCollection || 'posts';
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (args.
|
|
78
|
-
|
|
79
|
-
return formatToolError(new Error('action="diff" requires "filePath" parameter.'), ctx.meta);
|
|
80
|
-
}
|
|
81
|
-
const diffResult = diffConflict({
|
|
82
|
-
workspaceRoot: ctx.root,
|
|
83
|
-
filePath: args.filePath,
|
|
84
|
-
collection,
|
|
85
|
-
});
|
|
86
|
-
return formatToolSuccess(diffResult, ctx.meta);
|
|
61
|
+
if (args.action === 'list') {
|
|
62
|
+
const items = listConflicts(ctx.root, collection);
|
|
63
|
+
return formatToolSuccess({
|
|
64
|
+
conflicts: items,
|
|
65
|
+
count: items.length,
|
|
66
|
+
collection,
|
|
67
|
+
}, ctx.meta);
|
|
68
|
+
}
|
|
69
|
+
if (args.action === 'diff') {
|
|
70
|
+
if (!args.filePath) {
|
|
71
|
+
return formatToolError(new Error('action="diff" requires "filePath" parameter.'), ctx.meta);
|
|
87
72
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
filePath: args.filePath,
|
|
99
|
-
strategy: args.strategy,
|
|
100
|
-
force: args.force,
|
|
101
|
-
collection,
|
|
102
|
-
});
|
|
103
|
-
return formatToolSuccess(res, ctx.meta);
|
|
73
|
+
const diffResult = diffConflict({
|
|
74
|
+
workspaceRoot: ctx.root,
|
|
75
|
+
filePath: args.filePath,
|
|
76
|
+
collection,
|
|
77
|
+
});
|
|
78
|
+
return formatToolSuccess(diffResult, ctx.meta);
|
|
79
|
+
}
|
|
80
|
+
if (args.action === 'resolve') {
|
|
81
|
+
if (!args.filePath) {
|
|
82
|
+
return formatToolError(new Error('action="resolve" requires "filePath" parameter.'), ctx.meta);
|
|
104
83
|
}
|
|
105
|
-
if (args.
|
|
106
|
-
|
|
107
|
-
workspaceRoot: ctx.root,
|
|
108
|
-
cache: ctx.cache,
|
|
109
|
-
collection,
|
|
110
|
-
olderThan: args.olderThan,
|
|
111
|
-
dryRun: args.dryRun,
|
|
112
|
-
allowOrphanRescues: args.allowOrphanRescues,
|
|
113
|
-
});
|
|
114
|
-
return formatToolSuccess(res, ctx.meta);
|
|
84
|
+
if (!args.strategy) {
|
|
85
|
+
return formatToolError(new Error('action="resolve" requires "strategy" parameter ("accept-local" or "accept-canonical").'), ctx.meta);
|
|
115
86
|
}
|
|
116
|
-
|
|
87
|
+
const res = resolveConflict({
|
|
88
|
+
workspaceRoot: ctx.root,
|
|
89
|
+
cache: ctx.cache,
|
|
90
|
+
filePath: args.filePath,
|
|
91
|
+
strategy: args.strategy,
|
|
92
|
+
force: args.force,
|
|
93
|
+
collection,
|
|
94
|
+
});
|
|
95
|
+
return formatToolSuccess(res, ctx.meta);
|
|
117
96
|
}
|
|
118
|
-
|
|
119
|
-
|
|
97
|
+
if (args.action === 'prune') {
|
|
98
|
+
const res = pruneConflicts({
|
|
99
|
+
workspaceRoot: ctx.root,
|
|
100
|
+
cache: ctx.cache,
|
|
101
|
+
collection,
|
|
102
|
+
olderThan: args.olderThan,
|
|
103
|
+
dryRun: args.dryRun,
|
|
104
|
+
allowOrphanRescues: args.allowOrphanRescues,
|
|
105
|
+
});
|
|
106
|
+
return formatToolSuccess(res, ctx.meta);
|
|
120
107
|
}
|
|
121
|
-
|
|
108
|
+
return formatToolError(new Error(`Unknown action "${args.action}". Must be "list", "diff", "resolve", or "prune".`), ctx.meta);
|
|
109
|
+
}));
|
|
122
110
|
}
|
|
123
111
|
//# sourceMappingURL=sync-conflicts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-conflicts.js","sourceRoot":"","sources":["../../../src/mcp/tools/sync-conflicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,yBAAyB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mcp/tools/sync-delete.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"sync-delete.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-delete.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAG,IAAI,CAwD/F"}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { z } from 'zod';
|
|
23
23
|
import { deleteArticle } from '../../sync/delete.js';
|
|
24
|
-
import { formatToolError, formatToolSuccess } from '../tool-errors.js';
|
|
24
|
+
import { formatToolError, formatToolSuccess, withResolvedContext } from '../tool-errors.js';
|
|
25
25
|
export function registerSyncDeleteTool(server, resolveContext) {
|
|
26
26
|
server.tool('sync_delete', 'Safely delete an article from both the local workspace and remote EmDash server. Enforces strict safety guards: rejects deletion if unpushed local modifications exist, requires "allowDeletePublished: true" to delete published articles, saves an automatic rescue backup to posts/conflicts/<file>.deleted.md, and preserves referenced media files in media/.', {
|
|
27
27
|
filePath: z
|
|
@@ -46,37 +46,25 @@ export function registerSyncDeleteTool(server, resolveContext) {
|
|
|
46
46
|
.optional()
|
|
47
47
|
.describe('Collection name containing the article (defaults to "posts")'),
|
|
48
48
|
profile: z.string().optional().describe('Target profile name for multi-site setups'),
|
|
49
|
-
}, async (args) => {
|
|
50
|
-
let ctx;
|
|
51
|
-
try {
|
|
52
|
-
ctx = resolveContext(args.profile);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
return formatToolError(error);
|
|
56
|
-
}
|
|
49
|
+
}, async (args) => withResolvedContext(resolveContext, args, async (ctx) => {
|
|
57
50
|
if (!args.filePath && !args.id) {
|
|
58
51
|
return formatToolError(new Error('Please specify either "filePath" or "id" of the article to delete.'));
|
|
59
52
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
return formatToolError(error, ctx.meta);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
53
|
+
const collection = args.collection || ctx.config.defaultCollection;
|
|
54
|
+
const result = await deleteArticle({
|
|
55
|
+
workspaceRoot: ctx.root,
|
|
56
|
+
cache: ctx.cache,
|
|
57
|
+
filePath: args.filePath,
|
|
58
|
+
id: args.id,
|
|
59
|
+
collection,
|
|
60
|
+
allowDeletePublished: args.allowDeletePublished,
|
|
61
|
+
discardLocalEdits: args.discardLocalEdits,
|
|
62
|
+
dryRun: args.dryRun,
|
|
63
|
+
origin: ctx.origin,
|
|
64
|
+
token: ctx.auth?.token,
|
|
65
|
+
refreshToken: ctx.auth?.refreshToken,
|
|
66
|
+
});
|
|
67
|
+
return formatToolSuccess(result, ctx.meta);
|
|
68
|
+
}));
|
|
81
69
|
}
|
|
82
70
|
//# sourceMappingURL=sync-delete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-delete.js","sourceRoot":"","sources":["../../../src/mcp/tools/sync-delete.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-delete.js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C/B,OAAO,eAAe,CACpB,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAChF,CAAC;QACJ,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC;QACnE,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;YACjC,aAAa,EAAE,GAAG,CAAC,IAAI;YACvB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,UAAU;YACV,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK;YACtB,YAAY,EAAE,GAAG,CAAC,IAAI,EAAE,YAAY;SACrC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC,MAA4C,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACnF,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-diff.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-diff.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"sync-diff.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-diff.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAG,IAAI,CAyB7F"}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { z } from 'zod';
|
|
23
23
|
import { inspectArticleDiff } from '../../sync/diff.js';
|
|
24
|
-
import {
|
|
24
|
+
import { formatToolTextWithMeta, withResolvedContext } from '../tool-errors.js';
|
|
25
25
|
export function registerSyncDiffTool(server, resolveContext) {
|
|
26
26
|
server.tool('sync_diff', 'Display line-by-line differences between local article edits and the baseline snapshot/remote version before pushing. Useful for reviewing changes or diagnosing unpushed modifications.', {
|
|
27
27
|
filePath: z
|
|
@@ -30,35 +30,14 @@ export function registerSyncDiffTool(server, resolveContext) {
|
|
|
30
30
|
.describe('Relative path to the markdown file to inspect (e.g. "posts/draft/20261103_01...-my-article.md")'),
|
|
31
31
|
id: z.string().optional().describe('Article ID (ULID) to inspect'),
|
|
32
32
|
profile: z.string().optional().describe('Target profile name for multi-site setups'),
|
|
33
|
-
}, async (args) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ctx
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
inspection = inspectArticleDiff({
|
|
44
|
-
workspaceRoot: ctx.root,
|
|
45
|
-
cache: ctx.cache,
|
|
46
|
-
filePath: args.filePath,
|
|
47
|
-
id: args.id,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
return formatToolError(error, ctx.meta);
|
|
52
|
-
}
|
|
53
|
-
const metaSuffix = `\n\n_meta: ${JSON.stringify(ctx.meta)}`;
|
|
54
|
-
return {
|
|
55
|
-
content: [
|
|
56
|
-
{
|
|
57
|
-
type: 'text',
|
|
58
|
-
text: `${inspection.formattedOutput}${metaSuffix}`,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
};
|
|
62
|
-
});
|
|
33
|
+
}, async (args) => withResolvedContext(resolveContext, args, (ctx) => {
|
|
34
|
+
const inspection = inspectArticleDiff({
|
|
35
|
+
workspaceRoot: ctx.root,
|
|
36
|
+
cache: ctx.cache,
|
|
37
|
+
filePath: args.filePath,
|
|
38
|
+
id: args.id,
|
|
39
|
+
});
|
|
40
|
+
return formatToolTextWithMeta(inspection.formattedOutput, ctx.meta);
|
|
41
|
+
}));
|
|
63
42
|
}
|
|
64
43
|
//# sourceMappingURL=sync-diff.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-diff.js","sourceRoot":"","sources":["../../../src/mcp/tools/sync-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"sync-diff.js","sourceRoot":"","sources":["../../../src/mcp/tools/sync-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,cAA+B;IACrF,MAAM,CAAC,IAAI,CACT,WAAW,EACX,0LAA0L,EAC1L;QACE,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,iGAAiG,CAClG;QACH,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;QAClE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;KACrF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,mBAAmB,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;QAChD,MAAM,UAAU,GAAG,kBAAkB,CAAC;YACpC,aAAa,EAAE,GAAG,CAAC,IAAI;YACvB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,EAAE,EAAE,IAAI,CAAC,EAAE;SACZ,CAAC,CAAC;QACH,OAAO,sBAAsB,CAAC,UAAU,CAAC,eAAe,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-doctor.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-doctor.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"sync-doctor.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-doctor.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAG,IAAI,CAiD/F"}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { z } from 'zod';
|
|
23
23
|
import { runWorkspaceDoctor } from '../../sync/doctor.js';
|
|
24
|
-
import {
|
|
24
|
+
import { formatToolSuccess, withResolvedContext } from '../tool-errors.js';
|
|
25
25
|
export function registerSyncDoctorTool(server, resolveContext) {
|
|
26
26
|
server.tool('sync_doctor', 'Run comprehensive workspace diagnostics: verifies version compatibility, profile/config origin consistency, frontmatter syntax integrity across all articles, quarantined conflict copies, unpushed modifications, and referenced media existence.', {
|
|
27
27
|
collection: z
|
|
@@ -41,34 +41,22 @@ export function registerSyncDoctorTool(server, resolveContext) {
|
|
|
41
41
|
.boolean()
|
|
42
42
|
.optional()
|
|
43
43
|
.describe('Walk the whole remote media library via metadata only (GET /_emdash/api/media; no binary downloads) and report its record count against the number of assets this workspace mirrors, so a missing-file count reads as coverage instead of data loss'),
|
|
44
|
-
}, async (args) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
ctx
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
strictMedia: Boolean(args.strictMedia),
|
|
62
|
-
checkMediaUrls: Boolean(args.checkMediaUrls),
|
|
63
|
-
checkMediaLibrary: Boolean(args.checkMediaLibrary),
|
|
64
|
-
token: ctx.auth.token,
|
|
65
|
-
refreshToken: ctx.auth.refreshToken,
|
|
66
|
-
});
|
|
67
|
-
return formatToolSuccess(report, ctx.meta);
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
return formatToolError(err, ctx.meta);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
44
|
+
}, async (args) => withResolvedContext(resolveContext, args, async (ctx) => {
|
|
45
|
+
const collection = args.collection || ctx.config.defaultCollection || 'posts';
|
|
46
|
+
const report = await runWorkspaceDoctor({
|
|
47
|
+
workspaceRoot: ctx.root,
|
|
48
|
+
cache: ctx.cache,
|
|
49
|
+
config: ctx.config,
|
|
50
|
+
profileName: ctx.auth.profileName,
|
|
51
|
+
profileOrigin: ctx.auth.origin,
|
|
52
|
+
collection,
|
|
53
|
+
strictMedia: Boolean(args.strictMedia),
|
|
54
|
+
checkMediaUrls: Boolean(args.checkMediaUrls),
|
|
55
|
+
checkMediaLibrary: Boolean(args.checkMediaLibrary),
|
|
56
|
+
token: ctx.auth.token,
|
|
57
|
+
refreshToken: ctx.auth.refreshToken,
|
|
58
|
+
});
|
|
59
|
+
return formatToolSuccess(report, ctx.meta);
|
|
60
|
+
}));
|
|
73
61
|
}
|
|
74
62
|
//# sourceMappingURL=sync-doctor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-doctor.js","sourceRoot":"","sources":["../../../src/mcp/tools/sync-doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sync-doctor.js","sourceRoot":"","sources":["../../../src/mcp/tools/sync-doctor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,UAAU,sBAAsB,CAAC,MAAiB,EAAE,cAA+B;IACvF,MAAM,CAAC,IAAI,CACT,aAAa,EACb,oPAAoP,EACpP;QACE,UAAU,EAAE,CAAC;aACV,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,mEAAmE,CAAC;QAChF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;QACpF,WAAW,EAAE,CAAC;aACX,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CACP,iFAAiF,CAClF;QACH,cAAc,EAAE,CAAC;aACd,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CACP,uLAAuL,CACxL;QACH,iBAAiB,EAAE,CAAC;aACjB,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CACP,qPAAqP,CACtP;KACJ,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,mBAAmB,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACtD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI,OAAO,CAAC;QAC9E,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC;YACtC,aAAa,EAAE,GAAG,CAAC,IAAI;YACvB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW;YACjC,aAAa,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM;YAC9B,UAAU;YACV,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC;YACtC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC;YAC5C,iBAAiB,EAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC;YAClD,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK;YACrB,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY;SACpC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC,MAA4C,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACnF,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-media-search.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-media-search.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"sync-media-search.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-media-search.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,EACjB,cAAc,EAAE,eAAe,GAC9B,IAAI,CAsEN"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import { z } from 'zod';
|
|
23
23
|
import { collectLocalMirrorIndex, searchRemoteMedia } from '../../sync/media.js';
|
|
24
24
|
import { getLocalTaxonomiesSummary } from '../../sync/taxonomies.js';
|
|
25
|
-
import {
|
|
25
|
+
import { formatToolSuccess, withResolvedContext } from '../tool-errors.js';
|
|
26
26
|
export function registerSyncMediaSearchTool(server, resolveContext) {
|
|
27
27
|
server.tool('sync_media_search', 'Search the remote EmDash media library by keyword (filename, alt text, caption, storageKey, or local mirror stem) and report whether Emit already mirrors each hit. Returns up to 20 items plus walk coverage fields to conserve LLM context. Use "mirroredOnly:true" when only locally available assets matter. Absence is only proven when walkComplete is true — never conclude an asset does not exist from a truncated walk, and never propose inserting a media record.', {
|
|
28
28
|
query: z
|
|
@@ -43,60 +43,48 @@ export function registerSyncMediaSearchTool(server, resolveContext) {
|
|
|
43
43
|
.optional()
|
|
44
44
|
.describe('Append top local tag slugs as extra search hints'),
|
|
45
45
|
profile: z.string().optional().describe('Target profile name for multi-site setups'),
|
|
46
|
-
}, async (args) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
ctx
|
|
46
|
+
}, async (args) => withResolvedContext(resolveContext, args, async (ctx) => {
|
|
47
|
+
const mirrorIndex = collectLocalMirrorIndex(ctx.root, ctx.cache);
|
|
48
|
+
const result = await searchRemoteMedia({
|
|
49
|
+
workspaceRoot: ctx.root,
|
|
50
|
+
origin: ctx.origin,
|
|
51
|
+
token: ctx.auth.token,
|
|
52
|
+
refreshToken: ctx.auth.refreshToken,
|
|
53
|
+
query: args.query,
|
|
54
|
+
limit: args.limit,
|
|
55
|
+
maxScan: args.maxScan,
|
|
56
|
+
mirroredOnly: Boolean(args.mirroredOnly),
|
|
57
|
+
mirrorIndex,
|
|
58
|
+
});
|
|
59
|
+
let note = undefined;
|
|
60
|
+
if (!result.walkComplete) {
|
|
61
|
+
note = `[WALK_INCOMPLETE] read ${result.scannedCount} record(s) and stopped at maxScan; absence is not proven. Narrow the query or raise maxScan (0 walks the whole library).`;
|
|
50
62
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
workspaceRoot: ctx.root,
|
|
58
|
-
origin: ctx.origin,
|
|
59
|
-
token: ctx.auth.token,
|
|
60
|
-
refreshToken: ctx.auth.refreshToken,
|
|
61
|
-
query: args.query,
|
|
62
|
-
limit: args.limit,
|
|
63
|
-
maxScan: args.maxScan,
|
|
64
|
-
mirroredOnly: Boolean(args.mirroredOnly),
|
|
65
|
-
mirrorIndex,
|
|
66
|
-
});
|
|
67
|
-
let note = undefined;
|
|
68
|
-
if (!result.walkComplete) {
|
|
69
|
-
note = `[WALK_INCOMPLETE] read ${result.scannedCount} record(s) and stopped at maxScan; absence is not proven. Narrow the query or raise maxScan (0 walks the whole library).`;
|
|
70
|
-
}
|
|
71
|
-
let tagHints = undefined;
|
|
72
|
-
if (args.suggestKeywords) {
|
|
73
|
-
try {
|
|
74
|
-
const tax = getLocalTaxonomiesSummary(ctx.root);
|
|
75
|
-
if (tax.tags.length > 0) {
|
|
76
|
-
tagHints = tax.tags.slice(0, 10).map((t) => t.slug);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
// Taxonomy reading failure is non-fatal
|
|
63
|
+
let tagHints = undefined;
|
|
64
|
+
if (args.suggestKeywords) {
|
|
65
|
+
try {
|
|
66
|
+
const tax = getLocalTaxonomiesSummary(ctx.root);
|
|
67
|
+
if (tax.tags.length > 0) {
|
|
68
|
+
tagHints = tax.tags.slice(0, 10).map((t) => t.slug);
|
|
81
69
|
}
|
|
82
70
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
walkComplete: result.walkComplete,
|
|
87
|
-
totalCount: result.totalCount,
|
|
88
|
-
truncated: result.truncated,
|
|
89
|
-
hits: result.hits,
|
|
90
|
-
};
|
|
91
|
-
if (note)
|
|
92
|
-
payload.note = note;
|
|
93
|
-
if (tagHints)
|
|
94
|
-
payload.tagHints = tagHints;
|
|
95
|
-
return formatToolSuccess(payload, ctx.meta);
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
return formatToolError(err, ctx.meta);
|
|
71
|
+
catch {
|
|
72
|
+
// Taxonomy reading failure is non-fatal
|
|
73
|
+
}
|
|
99
74
|
}
|
|
100
|
-
|
|
75
|
+
const payload = {
|
|
76
|
+
query: args.query,
|
|
77
|
+
scannedCount: result.scannedCount,
|
|
78
|
+
walkComplete: result.walkComplete,
|
|
79
|
+
totalCount: result.totalCount,
|
|
80
|
+
truncated: result.truncated,
|
|
81
|
+
hits: result.hits,
|
|
82
|
+
};
|
|
83
|
+
if (note)
|
|
84
|
+
payload.note = note;
|
|
85
|
+
if (tagHints)
|
|
86
|
+
payload.tagHints = tagHints;
|
|
87
|
+
return formatToolSuccess(payload, ctx.meta);
|
|
88
|
+
}));
|
|
101
89
|
}
|
|
102
90
|
//# sourceMappingURL=sync-media-search.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-media-search.js","sourceRoot":"","sources":["../../../src/mcp/tools/sync-media-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sync-media-search.js","sourceRoot":"","sources":["../../../src/mcp/tools/sync-media-search.ts"],"names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ACF,IAAI,IAAI;YAAE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAC9B,IAAI,QAAQ;YAAE,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE1C,OAAO,iBAAiB,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-new.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-new.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"sync-new.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sync-new.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKrD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,GAAG,IAAI,CA6F5F"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import { z } from 'zod';
|
|
23
23
|
import { createArticleScaffold } from '../../sync/new.js';
|
|
24
24
|
import { getLocalTaxonomiesSummary, formatTaxonomiesHint } from '../../sync/taxonomies.js';
|
|
25
|
-
import {
|
|
25
|
+
import { formatToolTextWithMeta, withResolvedContext } from '../tool-errors.js';
|
|
26
26
|
export function registerSyncNewTool(server, resolveContext) {
|
|
27
27
|
server.tool('sync_new', 'Create a new article draft scaffold in posts/draft/ with standardized frontmatter (ULID, slug, title, default bylines). Returns the created relative file path and available categories/tags hints (sorted by usage) so you can edit the Markdown file directly before pushing.', {
|
|
28
28
|
slug: z.string().describe('URL slug for the new article'),
|
|
@@ -57,63 +57,42 @@ export function registerSyncNewTool(server, resolveContext) {
|
|
|
57
57
|
'or a 26-char remote media record ULID (e.g. "01M67P0MBMJQQXH2K95HHCYRYB"). ' +
|
|
58
58
|
'If a local draft path is given, Emit will automatically upload it and resolve the canonical ULID on sync_push.'),
|
|
59
59
|
profile: z.string().optional().describe('Target profile name for multi-site setups'),
|
|
60
|
-
}, async (args) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
}, async (args) => withResolvedContext(resolveContext, args, (ctx) => {
|
|
61
|
+
const collection = args.collection || ctx.config.defaultCollection;
|
|
62
|
+
const res = createArticleScaffold({
|
|
63
|
+
slug: args.slug,
|
|
64
|
+
workspaceRoot: ctx.root,
|
|
65
|
+
collection,
|
|
66
|
+
title: args.title,
|
|
67
|
+
locale: args.locale || ctx.config.defaultLocale,
|
|
68
|
+
byline: args.byline,
|
|
69
|
+
categories: args.categories,
|
|
70
|
+
tags: args.tags,
|
|
71
|
+
description: args.description,
|
|
72
|
+
featuredImage: args.featuredImage,
|
|
73
|
+
cache: ctx.cache,
|
|
74
|
+
});
|
|
75
|
+
const assignedParts = [];
|
|
76
|
+
if (res.assigned.categories.length > 0) {
|
|
77
|
+
assignedParts.push(`categories=[${res.assigned.categories.join(', ')}]`);
|
|
64
78
|
}
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
if (res.assigned.tags.length > 0) {
|
|
80
|
+
assignedParts.push(`tags=[${res.assigned.tags.join(', ')}]`);
|
|
67
81
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const res = createArticleScaffold({
|
|
71
|
-
slug: args.slug,
|
|
72
|
-
workspaceRoot: ctx.root,
|
|
73
|
-
collection,
|
|
74
|
-
title: args.title,
|
|
75
|
-
locale: args.locale || ctx.config.defaultLocale,
|
|
76
|
-
byline: args.byline,
|
|
77
|
-
categories: args.categories,
|
|
78
|
-
tags: args.tags,
|
|
79
|
-
description: args.description,
|
|
80
|
-
featuredImage: args.featuredImage,
|
|
81
|
-
cache: ctx.cache,
|
|
82
|
-
});
|
|
83
|
-
const assignedParts = [];
|
|
84
|
-
if (res.assigned.categories.length > 0) {
|
|
85
|
-
assignedParts.push(`categories=[${res.assigned.categories.join(', ')}]`);
|
|
86
|
-
}
|
|
87
|
-
if (res.assigned.tags.length > 0) {
|
|
88
|
-
assignedParts.push(`tags=[${res.assigned.tags.join(', ')}]`);
|
|
89
|
-
}
|
|
90
|
-
if (res.assigned.featuredImage) {
|
|
91
|
-
assignedParts.push(`featuredImage=${res.assigned.featuredImage}`);
|
|
92
|
-
}
|
|
93
|
-
if (res.assigned.description) {
|
|
94
|
-
assignedParts.push(`description="${res.assigned.description}"`);
|
|
95
|
-
}
|
|
96
|
-
const assignedBlock = assignedParts.length > 0 ? `\n- Assigned: ${assignedParts.join(', ')}` : '';
|
|
97
|
-
const warningBlock = res.warnings.length > 0
|
|
98
|
-
? `\n\n⚠️ Warnings:\n${res.warnings.map((w) => ` 👉 ${w}`).join('\n')}`
|
|
99
|
-
: '';
|
|
100
|
-
const taxSummary = getLocalTaxonomiesSummary(ctx.root);
|
|
101
|
-
const taxHint = formatTaxonomiesHint(taxSummary, { maxTags: 60 });
|
|
102
|
-
const hintBlock = taxHint ? `\n\n${taxHint}` : '';
|
|
103
|
-
const metaSuffix = `\n\n_meta: ${JSON.stringify(ctx.meta)}`;
|
|
104
|
-
return {
|
|
105
|
-
content: [
|
|
106
|
-
{
|
|
107
|
-
type: 'text',
|
|
108
|
-
text: `✅ Created new draft article '${args.slug}' (ID: ${res.id}) at ${res.filePath}.${assignedBlock}${warningBlock}${hintBlock}\n\nYou can now edit the file directly and sync it with sync_push.${metaSuffix}`,
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
};
|
|
82
|
+
if (res.assigned.featuredImage) {
|
|
83
|
+
assignedParts.push(`featuredImage=${res.assigned.featuredImage}`);
|
|
112
84
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return formatToolError(error, ctx?.meta);
|
|
85
|
+
if (res.assigned.description) {
|
|
86
|
+
assignedParts.push(`description="${res.assigned.description}"`);
|
|
116
87
|
}
|
|
117
|
-
|
|
88
|
+
const assignedBlock = assignedParts.length > 0 ? `\n- Assigned: ${assignedParts.join(', ')}` : '';
|
|
89
|
+
const warningBlock = res.warnings.length > 0
|
|
90
|
+
? `\n\n⚠️ Warnings:\n${res.warnings.map((w) => ` 👉 ${w}`).join('\n')}`
|
|
91
|
+
: '';
|
|
92
|
+
const taxSummary = getLocalTaxonomiesSummary(ctx.root);
|
|
93
|
+
const taxHint = formatTaxonomiesHint(taxSummary, { maxTags: 60 });
|
|
94
|
+
const hintBlock = taxHint ? `\n\n${taxHint}` : '';
|
|
95
|
+
return formatToolTextWithMeta(`✅ Created new draft article '${args.slug}' (ID: ${res.id}) at ${res.filePath}.${assignedBlock}${warningBlock}${hintBlock}\n\nYou can now edit the file directly and sync it with sync_push.`, ctx.meta);
|
|
96
|
+
}));
|
|
118
97
|
}
|
|
119
98
|
//# sourceMappingURL=sync-new.js.map
|