draftgo-cli 1.0.4 → 1.0.6
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/README.md +4 -4
- package/package.json +4 -3
- package/resources/skill/SKILL.md +4 -3
- package/resources/skill/manifest.json +1 -1
- package/resources/skill/references/ai.md +1 -1
- package/resources/skill/references/app-api.md +29 -27
- package/resources/skill/references/chat-sdk.md +10 -184
- package/resources/skill/references/checkout.md +43 -118
- package/resources/skill/references/development.md +0 -3
- package/resources/skill/references/frontend.md +10 -25
- package/resources/skill/references/mcp.md +15 -68
- package/resources/skill/references/methods.md +8 -11
- package/resources/skill/references/modules.md +24 -35
- package/resources/skill/references/runtime.md +11 -102
- package/resources/skill/references/services.md +89 -17
- package/src/commands/checkout.js +50 -3
- package/src/commands/commit.js +1 -1
- package/src/commands/conflict.js +1 -1
- package/src/commands/diff.js +1 -1
- package/src/commands/help.js +125 -125
- package/src/commands/map.js +60 -17
- package/src/commands/reconcile.js +1 -1
- package/src/commands/uninstall.js +16 -9
- package/src/mcp/hosts.js +68 -23
- package/src/platforms.js +16 -4
- package/src/skill.js +26 -6
- package/src/targets.js +2 -2
- package/src/worktree/backend.js +157 -21
- package/src/worktree/index.js +3 -0
- package/src/worktree/types.js +22 -18
package/src/commands/checkout.js
CHANGED
|
@@ -1,15 +1,62 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const log = require('../logger');
|
|
4
|
+
const { loadProjectConfig } = require('../projectConfig');
|
|
5
|
+
const { TOOL_NAMES, openToolSession } = require('../mcp/tools');
|
|
6
|
+
const { canonicalResourceType } = require('../worktree/types');
|
|
4
7
|
const { checkoutResources } = require('../worktree');
|
|
8
|
+
const map = require('./map');
|
|
9
|
+
|
|
10
|
+
const USAGE = 'Usage: draftgo checkout <pages|nav|docs|services> <id...>';
|
|
11
|
+
|
|
12
|
+
async function resolveUniqueHit(projectDir, resourceType, flags) {
|
|
13
|
+
const canonical = canonicalResourceType(resourceType);
|
|
14
|
+
if (canonical === 'services') {
|
|
15
|
+
log.err('Checkout --route and --title are not supported for services.');
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const config = loadProjectConfig(projectDir);
|
|
19
|
+
const resourceTypes = [map.normalizeMapResourceType(resourceType)];
|
|
20
|
+
const searching = flags.route != null || flags.title != null;
|
|
21
|
+
let remote;
|
|
22
|
+
try {
|
|
23
|
+
const session = await openToolSession(config, [searching ? TOOL_NAMES.resourceSearch : TOOL_NAMES.resourceList]);
|
|
24
|
+
remote = await map.listMapResources(session, resourceTypes, flags);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (!error || error.code !== 'MCP_TOOL_UNAVAILABLE') throw error;
|
|
27
|
+
const session = await openToolSession(config, [TOOL_NAMES.apiSearch, TOOL_NAMES.apiDescribe, TOOL_NAMES.apiCall]);
|
|
28
|
+
remote = await map.listRegistryResources(projectDir, config, session, resourceTypes, flags);
|
|
29
|
+
}
|
|
30
|
+
const matches = (remote && remote.resources || []).filter((resource) => map.resourceMatches(resource, flags));
|
|
31
|
+
if (matches.length === 0) {
|
|
32
|
+
log.err(`No ${canonical} matched the given --route/--title.`);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (matches.length !== 1) {
|
|
36
|
+
log.err(`Checkout --route/--title matched ${matches.length} ${canonical}; require exactly one.`);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return String(matches[0].resource_id);
|
|
40
|
+
}
|
|
5
41
|
|
|
6
42
|
async function checkout(projectDir, positional, flags = {}) {
|
|
7
43
|
const [resourceType, ...ids] = positional;
|
|
8
|
-
|
|
9
|
-
|
|
44
|
+
const selecting = flags.route != null || flags.title != null;
|
|
45
|
+
if (!resourceType || (!ids.length && !selecting)) {
|
|
46
|
+
log.err(USAGE);
|
|
10
47
|
return 1;
|
|
11
48
|
}
|
|
12
|
-
|
|
49
|
+
let resourceIds = ids;
|
|
50
|
+
if (selecting) {
|
|
51
|
+
if (ids.length) {
|
|
52
|
+
log.err('Checkout --route/--title cannot be combined with resource ids.');
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
const resourceId = await resolveUniqueHit(projectDir, resourceType, flags);
|
|
56
|
+
if (!resourceId) return 1;
|
|
57
|
+
resourceIds = [resourceId];
|
|
58
|
+
}
|
|
59
|
+
const results = await checkoutResources(projectDir, resourceType, resourceIds, { force: Boolean(flags.force) });
|
|
13
60
|
if (flags.output === 'json') console.log(JSON.stringify(results, null, 2));
|
|
14
61
|
else for (const entry of results) log.ok(`Checked out ${entry.resource_type} ${entry.resource_id} -> ${entry.local_path}`);
|
|
15
62
|
return 0;
|
package/src/commands/commit.js
CHANGED
|
@@ -6,7 +6,7 @@ const { commitResources } = require('../worktree');
|
|
|
6
6
|
async function commit(projectDir, positional, flags = {}) {
|
|
7
7
|
const [resourceType, ...ids] = positional;
|
|
8
8
|
if (!resourceType || !ids.length) {
|
|
9
|
-
log.err('Usage: draftgo commit <pages|nav|docs> <id...>');
|
|
9
|
+
log.err('Usage: draftgo commit <pages|nav|docs|services> <id...>');
|
|
10
10
|
return 1;
|
|
11
11
|
}
|
|
12
12
|
const streamed = [];
|
package/src/commands/conflict.js
CHANGED
|
@@ -15,7 +15,7 @@ function printRecord(record) {
|
|
|
15
15
|
async function conflict(projectDir, positional, flags = {}) {
|
|
16
16
|
const [action, resourceType, resourceId] = positional;
|
|
17
17
|
if (!['show', 'resolve'].includes(action) || !resourceType || !resourceId) {
|
|
18
|
-
log.err('Usage: draftgo conflict <show|resolve> <pages|nav|docs> <id>');
|
|
18
|
+
log.err('Usage: draftgo conflict <show|resolve> <pages|nav|docs|services> <id>');
|
|
19
19
|
return 1;
|
|
20
20
|
}
|
|
21
21
|
const record = action === 'show'
|
package/src/commands/diff.js
CHANGED
|
@@ -8,7 +8,7 @@ const { absolutePath } = require('../worktree/manifest');
|
|
|
8
8
|
function diff(projectDir, positional, flags = {}) {
|
|
9
9
|
const [resourceType, resourceId] = positional;
|
|
10
10
|
if (!resourceType || !resourceId) {
|
|
11
|
-
log.err('Usage: draftgo diff <pages|nav|docs> <id>');
|
|
11
|
+
log.err('Usage: draftgo diff <pages|nav|docs|services> <id>');
|
|
12
12
|
return 1;
|
|
13
13
|
}
|
|
14
14
|
const result = diffResource(projectDir, resourceType, resourceId);
|
package/src/commands/help.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { all } = require('../targets');
|
|
3
|
+
const { all } = require('../targets');
|
|
4
4
|
const { HOSTS } = require('../mcp/hosts');
|
|
5
5
|
const { getPackageVersion } = require('../skill');
|
|
6
6
|
|
|
@@ -13,158 +13,158 @@ function help() {
|
|
|
13
13
|
|
|
14
14
|
console.log(`draftgo v${getPackageVersion()} - DraftGo workbench CLI for AI coding agents
|
|
15
15
|
|
|
16
|
-
DraftGo shell baseline: React + Vite. Database Pages default to native HTML,
|
|
17
|
-
Tailwind CSS 4, and the DraftGo built-in component library (draftgo/*).
|
|
18
|
-
Provider brands and shared icons are served from the local /assets/providers and
|
|
19
|
-
/assets/icons directories; the Page runtime does not require third-party CDNs.
|
|
20
|
-
System MCP handles live discovery and structured resources; complete page,
|
|
21
|
-
navigation, and
|
|
22
|
-
The installed Skill routes agents to task-specific References and MCP tools.
|
|
16
|
+
DraftGo shell baseline: React + Vite. Database Pages default to native HTML,
|
|
17
|
+
Tailwind CSS 4, and the DraftGo built-in component library (draftgo/*).
|
|
18
|
+
Provider brands and shared icons are served from the local /assets/providers and
|
|
19
|
+
/assets/icons directories; the Page runtime does not require third-party CDNs.
|
|
20
|
+
System MCP handles live discovery and structured resources; complete page,
|
|
21
|
+
navigation, document, and Go source bodies use checkout/commit outside MCP context.
|
|
22
|
+
The installed Skill routes agents to task-specific References and MCP tools.
|
|
23
23
|
|
|
24
24
|
Usage:
|
|
25
|
-
draftgo init [<target>...] Install the DraftGo Skill. Omit the target
|
|
26
|
-
to detect host-owned directories such as
|
|
27
|
-
.cursor or .
|
|
28
|
-
AGENTS.md. Use "all" for every Skill target.
|
|
29
|
-
draftgo update [<target>...] Refresh already installed Skills. Does not
|
|
30
|
-
upgrade the global CLI. An explicit target
|
|
31
|
-
may also install that target when missing.
|
|
25
|
+
draftgo init [<target>...] Install the DraftGo Skill. Omit the target
|
|
26
|
+
to detect host-owned directories such as
|
|
27
|
+
.cursor, .codex, or .zcode, not shared files like
|
|
28
|
+
AGENTS.md. Use "all" for every Skill target.
|
|
29
|
+
draftgo update [<target>...] Refresh already installed Skills. Does not
|
|
30
|
+
upgrade the global CLI. An explicit target
|
|
31
|
+
may also install that target when missing.
|
|
32
32
|
draftgo uninstall <target|all> Remove Skill files. --purge also removes
|
|
33
33
|
the entire .draftgo/ runtime directory.
|
|
34
|
-
draftgo status Show connection health, Registry revision, targets, and Skill version.
|
|
34
|
+
draftgo status Show connection health, Registry revision, targets, and Skill version.
|
|
35
35
|
|
|
36
|
-
draftgo connect [<target>...] Verify and save server/API Key, then configure
|
|
36
|
+
draftgo connect [<target>...] Verify and save server/API Key, then configure
|
|
37
37
|
a detected or explicit MCP host. This never
|
|
38
38
|
downloads DraftGo business resources.
|
|
39
39
|
draftgo mcp setup [<target>...] Merge project-level stdio MCP configuration.
|
|
40
40
|
draftgo mcp status [<target>...] Check host configuration and secret safety.
|
|
41
|
-
draftgo mcp test Test project, resource, and API MCP calls.
|
|
42
|
-
draftgo mcp serve Bridge local stdio to the remote /mcp endpoint.
|
|
43
|
-
|
|
44
|
-
draftgo map [--type <type>] Locate bounded remote resource metadata and
|
|
45
|
-
overlay matching local checkout state.
|
|
46
|
-
Use --route/--title for exact selection.
|
|
47
|
-
draftgo checkout <type> <id...> Download a long-form body + verified base,
|
|
48
|
-
--force explicitly replaces local changes.
|
|
49
|
-
draftgo check Validate all checked-out content.
|
|
50
|
-
--remote also compares remote hash/version.
|
|
51
|
-
draftgo verify [<type> <id...>] Run the default delivery verification.
|
|
52
|
-
Browser options are explicit and optional.
|
|
53
|
-
draftgo diff <type> <id> Show checkout base versus local body/files.
|
|
54
|
-
--stat/--summary omit the full patch.
|
|
55
|
-
draftgo commit <type> <id...> Validate and upload complete checked-out bodies/files.
|
|
56
|
-
draftgo components search <query> Search the live component catalog.
|
|
57
|
-
draftgo components show <library/component>
|
|
58
|
-
Show HTML, props, slots, CSS variables and revision.
|
|
59
|
-
draftgo components expand --page <id> --instance <data-dg-instance>
|
|
60
|
-
Expand one component in a checked-out Page worktree.
|
|
61
|
-
draftgo components libraries list|show|create|update|delete
|
|
62
|
-
Manage component libraries.
|
|
63
|
-
draftgo components list|create|copy|delete
|
|
64
|
-
Manage component catalog entries.
|
|
65
|
-
draftgo components checkout|diff|verify|commit|publish <library/component>
|
|
66
|
-
Develop a component draft locally, then publish explicitly.
|
|
67
|
-
draftgo components import <zip> [--dry-run]
|
|
68
|
-
draftgo components export <library> [--file <zip>]
|
|
69
|
-
Transfer standard DraftGo component archives.
|
|
70
|
-
draftgo refresh <type> <id...> Safely refresh a clean checkout from the cloud.
|
|
71
|
-
draftgo reconcile <type> <id...> Repair stale metadata only when local equals remote.
|
|
41
|
+
draftgo mcp test Test project, resource, and API MCP calls.
|
|
42
|
+
draftgo mcp serve Bridge local stdio to the remote /mcp endpoint.
|
|
43
|
+
|
|
44
|
+
draftgo map [--type <type>] Locate bounded remote resource metadata and
|
|
45
|
+
overlay matching local checkout state.
|
|
46
|
+
Use --route/--title for exact selection.
|
|
47
|
+
draftgo checkout <type> <id...> Download a long-form body + verified base,
|
|
48
|
+
--force explicitly replaces local changes.
|
|
49
|
+
draftgo check Validate all checked-out content.
|
|
50
|
+
--remote also compares remote hash/version.
|
|
51
|
+
draftgo verify [<type> <id...>] Run the default delivery verification.
|
|
52
|
+
Browser options are explicit and optional.
|
|
53
|
+
draftgo diff <type> <id> Show checkout base versus local body/files.
|
|
54
|
+
--stat/--summary omit the full patch.
|
|
55
|
+
draftgo commit <type> <id...> Validate and upload complete checked-out bodies/files.
|
|
56
|
+
draftgo components search <query> Search the live component catalog.
|
|
57
|
+
draftgo components show <library/component>
|
|
58
|
+
Show HTML, props, slots, CSS variables and revision.
|
|
59
|
+
draftgo components expand --page <id> --instance <data-dg-instance>
|
|
60
|
+
Expand one component in a checked-out Page worktree.
|
|
61
|
+
draftgo components libraries list|show|create|update|delete
|
|
62
|
+
Manage component libraries.
|
|
63
|
+
draftgo components list|create|copy|delete
|
|
64
|
+
Manage component catalog entries.
|
|
65
|
+
draftgo components checkout|diff|verify|commit|publish <library/component>
|
|
66
|
+
Develop a component draft locally, then publish explicitly.
|
|
67
|
+
draftgo components import <zip> [--dry-run]
|
|
68
|
+
draftgo components export <library> [--file <zip>]
|
|
69
|
+
Transfer standard DraftGo component archives.
|
|
70
|
+
draftgo refresh <type> <id...> Safely refresh a clean checkout from the cloud.
|
|
71
|
+
draftgo reconcile <type> <id...> Repair stale metadata only when local equals remote.
|
|
72
72
|
draftgo conflicts List unresolved conflicts; --all includes resolved.
|
|
73
73
|
draftgo conflict show <type> <id>
|
|
74
74
|
Show preserved base/local/remote paths.
|
|
75
75
|
draftgo conflict resolve <type> <id>
|
|
76
76
|
Mark a merged worktree file ready against the
|
|
77
77
|
preserved remote base; then check/diff/commit.
|
|
78
|
-
draftgo clean [--dry-run|--yes] Plan or remove all tmp and registered artifacts.
|
|
79
|
-
draftgo work start <item> Add an active item to .draftgo/worklog.md.
|
|
80
|
-
draftgo work add <item> Add an item awaiting a decision.
|
|
81
|
-
draftgo work wait <ref> Mark an item waiting; --note records the reason.
|
|
82
|
-
draftgo work start-item <ref> Mark an item active; ref is number or date#number.
|
|
83
|
-
draftgo work complete <ref> Mark an item complete; --note appends evidence.
|
|
84
|
-
draftgo work show [<ref>] Show all history or one item with notes.
|
|
85
|
-
draftgo work list Latest first; --status active|waiting|completed,
|
|
86
|
-
--date YYYY-MM-DD, --limit 1-100 (20), --offset N.
|
|
78
|
+
draftgo clean [--dry-run|--yes] Plan or remove all tmp and registered artifacts.
|
|
79
|
+
draftgo work start <item> Add an active item to .draftgo/worklog.md.
|
|
80
|
+
draftgo work add <item> Add an item awaiting a decision.
|
|
81
|
+
draftgo work wait <ref> Mark an item waiting; --note records the reason.
|
|
82
|
+
draftgo work start-item <ref> Mark an item active; ref is number or date#number.
|
|
83
|
+
draftgo work complete <ref> Mark an item complete; --note appends evidence.
|
|
84
|
+
draftgo work show [<ref>] Show all history or one item with notes.
|
|
85
|
+
draftgo work list Latest first; --status active|waiting|completed,
|
|
86
|
+
--date YYYY-MM-DD, --limit 1-100 (20), --offset N.
|
|
87
87
|
|
|
88
|
-
draftgo api <query> Search the live API contract through MCP.
|
|
89
|
-
draftgo api search <query> Search the live operation registry explicitly.
|
|
90
|
-
draftgo api describe <operation_id>
|
|
91
|
-
Describe one live API operation through MCP.
|
|
92
|
-
draftgo api call <operation_id> --input <json-file>
|
|
93
|
-
Call one described operation with UTF-8 JSON.
|
|
94
|
-
draftgo capabilities list|search|show|audit
|
|
95
|
-
Discover and audit the current server's live operation catalog.
|
|
96
|
-
draftgo group <action> Manage RBAC groups and group members.
|
|
97
|
-
draftgo api-key status|create|update|delete|rotate
|
|
98
|
-
Manage the current user's API key through MCP.
|
|
99
|
-
draftgo role permissions|list|create|get|update|delete
|
|
100
|
-
Manage structured permission templates.
|
|
101
|
-
draftgo delete <operation_id> [id]
|
|
102
|
-
Confirm and call a live delete operation.
|
|
88
|
+
draftgo api <query> Search the live API contract through MCP.
|
|
89
|
+
draftgo api search <query> Search the live operation registry explicitly.
|
|
90
|
+
draftgo api describe <operation_id>
|
|
91
|
+
Describe one live API operation through MCP.
|
|
92
|
+
draftgo api call <operation_id> --input <json-file>
|
|
93
|
+
Call one described operation with UTF-8 JSON.
|
|
94
|
+
draftgo capabilities list|search|show|audit
|
|
95
|
+
Discover and audit the current server's live operation catalog.
|
|
96
|
+
draftgo group <action> Manage RBAC groups and group members.
|
|
97
|
+
draftgo api-key status|create|update|delete|rotate
|
|
98
|
+
Manage the current user's API key through MCP.
|
|
99
|
+
draftgo role permissions|list|create|get|update|delete
|
|
100
|
+
Manage structured permission templates.
|
|
101
|
+
draftgo delete <operation_id> [id]
|
|
102
|
+
Confirm and call a live delete operation.
|
|
103
103
|
draftgo deploy [<type> <id...>] Check, then diff or commit checked-out content.
|
|
104
104
|
--delivery local needs no IDs; preview/deploy
|
|
105
105
|
require an explicit type and IDs.
|
|
106
|
-
draftgo auto-push [<type> <id...>]
|
|
107
|
-
With config.auto_push=true, check and commit
|
|
108
|
-
changed checkouts. Any conflict stops the run.
|
|
109
|
-
draftgo local setup|start|stop|logs|status
|
|
110
|
-
Manage the project-local Docker stack.
|
|
106
|
+
draftgo auto-push [<type> <id...>]
|
|
107
|
+
With config.auto_push=true, check and commit
|
|
108
|
+
changed checkouts. Any conflict stops the run.
|
|
109
|
+
draftgo local setup|start|stop|logs|status
|
|
110
|
+
Manage the project-local Docker stack.
|
|
111
111
|
draftgo list-targets List Skill installation targets.
|
|
112
112
|
draftgo -v | --version Print CLI version.
|
|
113
113
|
draftgo -h | --help Show this help.
|
|
114
114
|
|
|
115
|
-
Resource types:
|
|
116
|
-
pages | nav/navigations | docs/articles
|
|
115
|
+
Resource types:
|
|
116
|
+
pages | nav/navigations | docs/articles | services
|
|
117
117
|
|
|
118
118
|
Important flags:
|
|
119
119
|
--project <dir> Operate on <dir> instead of the current directory.
|
|
120
120
|
--target <name,...> Select one or more MCP setup/status targets.
|
|
121
|
-
--server <url> (connect) DraftGo base URL.
|
|
122
|
-
--mcp-url <url> (connect) Explicit endpoint; standard /mcp derives the
|
|
123
|
-
base URL; custom paths also need --server.
|
|
124
|
-
--api-key <key> (connect) DraftGo user API Key for non-interactive use.
|
|
125
|
-
--timeout <ms> (connect/mcp test) Network timeout.
|
|
121
|
+
--server <url> (connect) DraftGo base URL.
|
|
122
|
+
--mcp-url <url> (connect) Explicit endpoint; standard /mcp derives the
|
|
123
|
+
base URL; custom paths also need --server.
|
|
124
|
+
--api-key <key> (connect) DraftGo user API Key for non-interactive use.
|
|
125
|
+
--timeout <ms> (connect/mcp test) Network timeout.
|
|
126
126
|
--allow-offline (connect) Save only after explicitly accepting a
|
|
127
127
|
failed MCP validation.
|
|
128
128
|
--no-mcp-setup (connect) Do not write host MCP configuration.
|
|
129
129
|
--force (init/checkout) Overwrite Skill or local changes.
|
|
130
130
|
--purge (uninstall) Also remove the .draftgo/ directory.
|
|
131
|
-
--skip-update-check (update) Compatibility flag; update never upgrades CLI.
|
|
132
|
-
--connect (init) Continue into DraftGo server connection.
|
|
133
|
-
--no-setup (init) Install the Skill without either setup flow.
|
|
134
|
-
--output json Print machine-readable output where supported.
|
|
135
|
-
--type <type> (map) pages | nav/navigations | docs/articles;
|
|
136
|
-
(capabilities) alias for a Registry module filter.
|
|
137
|
-
--route <path> (map) Select resources with this exact route.
|
|
138
|
-
--title <title> (map) Select resources with this exact title.
|
|
139
|
-
--limit <1-100> (map) Maximum resources returned per type/page;
|
|
140
|
-
defaults to 20.
|
|
141
|
-
--cursor <cursor> (map) Continue one typed map result page.
|
|
142
|
-
--summary (map/diff) Print bounded resource or change summary.
|
|
143
|
-
--stat (diff) Print per-file and total change statistics.
|
|
144
|
-
--strict Treat check warnings as failures.
|
|
145
|
-
--remote (check) Compare checkout hashes/versions with remote.
|
|
131
|
+
--skip-update-check (update) Compatibility flag; update never upgrades CLI.
|
|
132
|
+
--connect (init) Continue into DraftGo server connection.
|
|
133
|
+
--no-setup (init) Install the Skill without either setup flow.
|
|
134
|
+
--output json Print machine-readable output where supported.
|
|
135
|
+
--type <type> (map) pages | nav/navigations | docs/articles;
|
|
136
|
+
(capabilities) alias for a Registry module filter.
|
|
137
|
+
--route <path> (map/checkout) Select resources with this exact route.
|
|
138
|
+
--title <title> (map/checkout) Select resources with this exact title.
|
|
139
|
+
--limit <1-100> (map) Maximum resources returned per type/page;
|
|
140
|
+
defaults to 20.
|
|
141
|
+
--cursor <cursor> (map) Continue one typed map result page.
|
|
142
|
+
--summary (map/diff) Print bounded resource or change summary.
|
|
143
|
+
--stat (diff) Print per-file and total change statistics.
|
|
144
|
+
--strict Treat check warnings as failures.
|
|
145
|
+
--remote (check) Compare checkout hashes/versions with remote.
|
|
146
146
|
--yes Skip supported confirmation prompts.
|
|
147
147
|
--operation-id <id> (delete) Select an operation explicitly.
|
|
148
|
-
--params <json> (api call/delete) Pass an API parameter object.
|
|
149
|
-
--input <file> (api call/delete) Read a UTF-8 JSON object.
|
|
150
|
-
--delivery <mode> (deploy) local | preview | deploy.
|
|
151
|
-
--dry-run Preview supported cleanup or delivery operations.
|
|
152
|
-
--ui <mode> (verify) always | never; default never.
|
|
153
|
-
--remote (check/verify) Compare checkout hashes with remote.
|
|
154
|
-
--viewport <mode> (verify) mobile | desktop | both.
|
|
155
|
-
--frame <mode> (verify) auto | top | all | <iframe-selector>.
|
|
156
|
-
--token <mode> (verify) auto | never; auto appends the configured
|
|
157
|
-
API Key to same-origin URLs as the token query parameter.
|
|
158
|
-
--screenshot <mode> (verify) always | never; always alone captures a screenshot.
|
|
159
|
-
--browser <name> (verify) chromium | chrome | msedge.
|
|
160
|
-
--browser-path <file> (verify) Explicit browser executable; environment
|
|
161
|
-
fallback: DRAFTGO_BROWSER_PATH.
|
|
162
|
-
--selector <css> (verify) Require a visible element in top or iframe DOM.
|
|
163
|
-
--width/--height <px> (verify) Override the default 1440x900 desktop viewport.
|
|
148
|
+
--params <json> (api call/delete) Pass an API parameter object.
|
|
149
|
+
--input <file> (api call/delete) Read a UTF-8 JSON object.
|
|
150
|
+
--delivery <mode> (deploy) local | preview | deploy.
|
|
151
|
+
--dry-run Preview supported cleanup or delivery operations.
|
|
152
|
+
--ui <mode> (verify) always | never; default never.
|
|
153
|
+
--remote (check/verify) Compare checkout hashes with remote.
|
|
154
|
+
--viewport <mode> (verify) mobile | desktop | both.
|
|
155
|
+
--frame <mode> (verify) auto | top | all | <iframe-selector>.
|
|
156
|
+
--token <mode> (verify) auto | never; auto appends the configured
|
|
157
|
+
API Key to same-origin URLs as the token query parameter.
|
|
158
|
+
--screenshot <mode> (verify) always | never; always alone captures a screenshot.
|
|
159
|
+
--browser <name> (verify) chromium | chrome | msedge.
|
|
160
|
+
--browser-path <file> (verify) Explicit browser executable; environment
|
|
161
|
+
fallback: DRAFTGO_BROWSER_PATH.
|
|
162
|
+
--selector <css> (verify) Require a visible element in top or iframe DOM.
|
|
163
|
+
--width/--height <px> (verify) Override the default 1440x900 desktop viewport.
|
|
164
164
|
|
|
165
165
|
Security:
|
|
166
|
-
.draftgo/config.json stores the server and API Key and is gitignored. Host MCP
|
|
167
|
-
files contain only "draftgo mcp serve"; they never contain the API Key.
|
|
166
|
+
.draftgo/config.json stores the server and API Key and is gitignored. Host MCP
|
|
167
|
+
files contain only "draftgo mcp serve"; they never contain the API Key.
|
|
168
168
|
|
|
169
169
|
MCP targets (project config or status):
|
|
170
170
|
${mcpTargets}
|
|
@@ -174,15 +174,15 @@ ${targets}
|
|
|
174
174
|
|
|
175
175
|
Examples:
|
|
176
176
|
draftgo init codex
|
|
177
|
-
draftgo connect codex --server https://draftgo.example --api-key <key>
|
|
178
|
-
draftgo mcp test
|
|
179
|
-
draftgo map --type pages --route /admin/channel-ops --summary --output json
|
|
177
|
+
draftgo connect codex --server https://draftgo.example --api-key <key>
|
|
178
|
+
draftgo mcp test
|
|
179
|
+
draftgo map --type pages --route /admin/channel-ops --summary --output json
|
|
180
180
|
draftgo checkout pages 42
|
|
181
|
-
draftgo verify pages 42
|
|
182
|
-
draftgo diff pages 42 --stat
|
|
183
|
-
draftgo commit pages 42
|
|
184
|
-
draftgo work start "Build document management and role permissions"
|
|
185
|
-
draftgo work complete 1 --note "Verification and delivery passed"
|
|
181
|
+
draftgo verify pages 42
|
|
182
|
+
draftgo diff pages 42 --stat
|
|
183
|
+
draftgo commit pages 42
|
|
184
|
+
draftgo work start "Build document management and role permissions"
|
|
185
|
+
draftgo work complete 1 --note "Verification and delivery passed"
|
|
186
186
|
draftgo deploy docs 7 --delivery preview
|
|
187
187
|
`);
|
|
188
188
|
}
|
package/src/commands/map.js
CHANGED
|
@@ -19,6 +19,9 @@ const LIST_OPERATIONS = Object.freeze({
|
|
|
19
19
|
navigations: 'listNavigation',
|
|
20
20
|
'docs/articles': 'listDocAdminArticle',
|
|
21
21
|
});
|
|
22
|
+
const EXACT_ROUTE_OPERATIONS = Object.freeze({
|
|
23
|
+
pages: 'listPageByRoute',
|
|
24
|
+
});
|
|
22
25
|
|
|
23
26
|
function itemsFrom(value) {
|
|
24
27
|
if (Array.isArray(value)) return value;
|
|
@@ -29,6 +32,15 @@ function itemsFrom(value) {
|
|
|
29
32
|
return [];
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
function resourcesFrom(value) {
|
|
36
|
+
const items = itemsFrom(value);
|
|
37
|
+
if (items.length) return items;
|
|
38
|
+
if (value && typeof value === 'object' && (value.id != null || value.resource_id != null)) {
|
|
39
|
+
return [value];
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
|
|
32
44
|
function nextCursor(value) {
|
|
33
45
|
if (!value || typeof value !== 'object') return null;
|
|
34
46
|
if (Object.prototype.hasOwnProperty.call(value, 'next_cursor')) return value.next_cursor;
|
|
@@ -70,20 +82,28 @@ function queryProperties(operation) {
|
|
|
70
82
|
return query && query.properties && typeof query.properties === 'object' ? query.properties : {};
|
|
71
83
|
}
|
|
72
84
|
|
|
85
|
+
function registryOperationID(type, flags) {
|
|
86
|
+
return flags.route != null && EXACT_ROUTE_OPERATIONS[type]
|
|
87
|
+
? EXACT_ROUTE_OPERATIONS[type]
|
|
88
|
+
: LIST_OPERATIONS[type];
|
|
89
|
+
}
|
|
90
|
+
|
|
73
91
|
function registryQuery(operation, operationID, flags) {
|
|
74
92
|
const properties = queryProperties(operation);
|
|
75
93
|
const query = {};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (cursor)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
if (operationID !== 'listPageByRoute') {
|
|
95
|
+
const limit = positiveLimit(flags.limit);
|
|
96
|
+
const cursor = flags.cursor == null ? '' : String(flags.cursor);
|
|
97
|
+
if (Object.prototype.hasOwnProperty.call(properties, 'cursor')) {
|
|
98
|
+
if (cursor) query.cursor = cursor;
|
|
99
|
+
if (Object.prototype.hasOwnProperty.call(properties, 'limit')) query.limit = limit;
|
|
100
|
+
} else if (Object.prototype.hasOwnProperty.call(properties, 'page')
|
|
101
|
+
&& Object.prototype.hasOwnProperty.call(properties, 'page_size')) {
|
|
102
|
+
query.page = registryPageFromCursor(cursor, operationID);
|
|
103
|
+
query.page_size = limit;
|
|
104
|
+
} else if (cursor) {
|
|
105
|
+
throw new Error(`${operationID} does not expose a paginated Registry contract.`);
|
|
106
|
+
}
|
|
87
107
|
}
|
|
88
108
|
|
|
89
109
|
const search = flags.route != null ? normalizeRoute(flags.route)
|
|
@@ -93,6 +113,7 @@ function registryQuery(operation, operationID, flags) {
|
|
|
93
113
|
? 'route'
|
|
94
114
|
: ['search', 'q', 'query'].find((candidate) => Object.prototype.hasOwnProperty.call(properties, candidate));
|
|
95
115
|
if (key) query[key] = search;
|
|
116
|
+
else if (operationID === 'listPageByRoute') query.route = search;
|
|
96
117
|
}
|
|
97
118
|
return query;
|
|
98
119
|
}
|
|
@@ -131,10 +152,22 @@ function requestedResourceTypes(flags = {}) {
|
|
|
131
152
|
: [normalizeMapResourceType(flags.type)];
|
|
132
153
|
}
|
|
133
154
|
|
|
155
|
+
function recoverCliRoute(value) {
|
|
156
|
+
// Git Bash converts POSIX paths like /admin/channel-ops into a Windows path
|
|
157
|
+
// under the Git install root. Recover the original route before matching.
|
|
158
|
+
const text = String(value == null ? '' : value).trim().replace(/\\/g, '/');
|
|
159
|
+
const converted = text.match(/^[A-Za-z]:\/(?:[^/]+\/)*Git(\/.*)$/i);
|
|
160
|
+
return converted ? converted[1] : text;
|
|
161
|
+
}
|
|
162
|
+
|
|
134
163
|
function normalizeRoute(value) {
|
|
135
|
-
// DraftGo stores page routes
|
|
136
|
-
//
|
|
137
|
-
|
|
164
|
+
// DraftGo stores page routes with a leading slash and no trailing slash,
|
|
165
|
+
// except for `/`. Accept stored, browser, and Git-Bash-converted forms.
|
|
166
|
+
let route = recoverCliRoute(value);
|
|
167
|
+
if (!route) return '';
|
|
168
|
+
if (!route.startsWith('/')) route = `/${route}`;
|
|
169
|
+
if (route !== '/') route = route.replace(/\/+$/g, '');
|
|
170
|
+
return route;
|
|
138
171
|
}
|
|
139
172
|
|
|
140
173
|
function positiveLimit(value, fallback = 20) {
|
|
@@ -209,7 +242,7 @@ async function listRegistryResources(projectDir, config, session, resourceTypes,
|
|
|
209
242
|
throw new Error('Map --cursor requires exactly one --type.');
|
|
210
243
|
}
|
|
211
244
|
const groups = await allWithAbort(resourceTypes.map((type) => async (options) => {
|
|
212
|
-
const operationID =
|
|
245
|
+
const operationID = registryOperationID(type, flags);
|
|
213
246
|
const revision = await registryRevision(session, operationID);
|
|
214
247
|
const description = await descriptionForRevision(projectDir, config, session, operationID, revision);
|
|
215
248
|
const operation = description.operation || {};
|
|
@@ -220,16 +253,25 @@ async function listRegistryResources(projectDir, config, session, resourceTypes,
|
|
|
220
253
|
};
|
|
221
254
|
if (Object.keys(query).length) invoke.query = query;
|
|
222
255
|
const payload = await callStructured(session, TOOL_NAMES.apiCall, invoke, options);
|
|
256
|
+
const status = payload && (payload.status_code ?? payload.statusCode);
|
|
257
|
+
if (Number(status) === 404) {
|
|
258
|
+
return {
|
|
259
|
+
resources: [],
|
|
260
|
+
pagination: { next_cursor: null, has_more: false, total: 0 },
|
|
261
|
+
};
|
|
262
|
+
}
|
|
223
263
|
const response = payload && payload.response !== undefined ? payload.response
|
|
224
264
|
: payload && payload.data !== undefined ? payload.data : payload;
|
|
225
|
-
const responseItems =
|
|
265
|
+
const responseItems = resourcesFrom(response);
|
|
226
266
|
const resources = responseItems
|
|
227
267
|
.map((item) => ({ ...item, resource_type: type, resource_id: String(item.resource_id ?? item.id) }))
|
|
228
268
|
.filter((item) => item.resource_id && item.resource_id !== 'undefined')
|
|
229
269
|
.filter((item) => resourceMatches(item, flags));
|
|
230
270
|
return {
|
|
231
271
|
resources,
|
|
232
|
-
pagination:
|
|
272
|
+
pagination: operationID === 'listPageByRoute'
|
|
273
|
+
? { next_cursor: null, has_more: false, total: resources.length }
|
|
274
|
+
: registryPagination(response, operationID, query, responseItems.length),
|
|
233
275
|
};
|
|
234
276
|
}));
|
|
235
277
|
return {
|
|
@@ -378,6 +420,7 @@ async function mapCommand(projectDir, flags = {}) {
|
|
|
378
420
|
|
|
379
421
|
module.exports = mapCommand;
|
|
380
422
|
module.exports.itemsFrom = itemsFrom;
|
|
423
|
+
module.exports.resourcesFrom = resourcesFrom;
|
|
381
424
|
module.exports.normalizeMapResourceType = normalizeMapResourceType;
|
|
382
425
|
module.exports.requestedResourceTypes = requestedResourceTypes;
|
|
383
426
|
module.exports.listRemoteResources = listRemoteResources;
|
|
@@ -6,7 +6,7 @@ const { reconcileResources } = require('../worktree');
|
|
|
6
6
|
async function reconcile(projectDir, positional, flags = {}) {
|
|
7
7
|
const [resourceType, ...ids] = positional;
|
|
8
8
|
if (!resourceType || !ids.length) {
|
|
9
|
-
log.err('Usage: draftgo reconcile <pages|nav|docs> <id...>');
|
|
9
|
+
log.err('Usage: draftgo reconcile <pages|nav|docs|services> <id...>');
|
|
10
10
|
return 1;
|
|
11
11
|
}
|
|
12
12
|
const results = await reconcileResources(projectDir, resourceType, ids);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const log = require('../logger');
|
|
4
|
-
const { all, resolveTargets } = require('../targets');
|
|
4
|
+
const { all, resolveTargets } = require('../targets');
|
|
5
5
|
const { removePath } = require('../fsx');
|
|
6
6
|
const { dgDir } = require('../paths');
|
|
7
7
|
|
|
@@ -25,11 +25,18 @@ async function uninstall(projectDir, positional, flags) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
const resolvedNames = new Set(resolved.map((target) => target.name));
|
|
28
29
|
log.step('移除入口文件');
|
|
29
30
|
for (const t of resolved) {
|
|
30
31
|
try {
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const keepSharedSkill = all.some((other) =>
|
|
33
|
+
other.name !== t.name
|
|
34
|
+
&& !resolvedNames.has(other.name)
|
|
35
|
+
&& other.assetDir === t.assetDir
|
|
36
|
+
&& other.mainFile === t.mainFile);
|
|
37
|
+
const removed = t.uninstall(projectDir, { keepSharedSkill });
|
|
38
|
+
if (keepSharedSkill) log.dim(`${t.displayName} 与其他宿主共用 Skill 目录,已保留`);
|
|
39
|
+
else if (removed) log.ok(`${t.displayName} 入口已移除`);
|
|
33
40
|
else log.dim(`${t.displayName} 入口不存在,跳过`);
|
|
34
41
|
} catch (e) {
|
|
35
42
|
log.err(`${t.displayName} 卸载失败:${e.message}`);
|
|
@@ -38,12 +45,12 @@ async function uninstall(projectDir, positional, flags) {
|
|
|
38
45
|
|
|
39
46
|
// Each AI-tool skill directory is self-contained, so per-target uninstall
|
|
40
47
|
// already wiped its content above. Only --purge nukes runtime data under
|
|
41
|
-
// .draftgo/ (config/worklog/lessons/cache etc.).
|
|
42
|
-
if (flags.purge) {
|
|
43
|
-
if (removePath(dgDir(projectDir))) {
|
|
44
|
-
log.warn('已使用 --purge:.draftgo/(含 config/worklog/lessons 等运行时数据)已删除。');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
48
|
+
// .draftgo/ (config/worklog/lessons/cache etc.).
|
|
49
|
+
if (flags.purge) {
|
|
50
|
+
if (removePath(dgDir(projectDir))) {
|
|
51
|
+
log.warn('已使用 --purge:.draftgo/(含 config/worklog/lessons 等运行时数据)已删除。');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
47
54
|
|
|
48
55
|
log.title('完成');
|
|
49
56
|
return 0;
|