@drafthq/draft 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +10 -8
- package/cli/src/hosts/claude-code.js +33 -32
- package/cli/src/installer.js +47 -4
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"name": "draft",
|
|
13
13
|
"source": "./",
|
|
14
14
|
"description": "Context-Driven Development: draft specs and plans before implementation. Structured workflows for features and fixes.",
|
|
15
|
-
"version": "2.7.
|
|
15
|
+
"version": "2.7.1",
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "mayurpise"
|
|
18
18
|
},
|
package/README.md
CHANGED
|
@@ -62,16 +62,18 @@ draft install <host>
|
|
|
62
62
|
draft list # show every host + where it installs
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|------|-------------------|----------|
|
|
67
|
-
| **Claude Code** | `claude-code` | `./.claude-plugin/` + `skills/` `core/` (project) |
|
|
68
|
-
| **Cursor** | `cursor` | `~/.cursor/plugins/local/draft/` (global) |
|
|
69
|
-
| **Codex** | `codex` | `./AGENTS.md` (project) |
|
|
70
|
-
| **opencode** | `opencode` | `./AGENTS.md` + `~/.agents/skills/draft/` |
|
|
65
|
+
Each host installs the way that host actually loads extensions — no manual steps after the command:
|
|
71
66
|
|
|
72
|
-
|
|
67
|
+
| Host | `draft install …` | What it does |
|
|
68
|
+
|------|-------------------|--------------|
|
|
69
|
+
| **Claude Code** | `claude-code` | Registers the plugin via `claude plugin marketplace add` + `claude plugin install` (user scope). Restart Claude Code. |
|
|
70
|
+
| **Cursor** | `cursor` | Copies the plugin into `~/.cursor/plugins/local/draft/` (auto-loaded). Restart Cursor. |
|
|
71
|
+
| **Codex** | `codex` | Writes `./AGENTS.md`, which Codex reads automatically. |
|
|
72
|
+
| **opencode** | `opencode` | Writes `./AGENTS.md` + `~/.agents/skills/draft/`, both auto-discovered. |
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Flags: `--global` / `--project` to pick scope, `--dry-run` to preview, `--force` to overwrite, `--no-graph` to skip the graph-engine fetch.
|
|
75
|
+
|
|
76
|
+
Then, in Claude Code (after restarting):
|
|
75
77
|
|
|
76
78
|
```bash
|
|
77
79
|
/draft:init # 5-phase codebase analysis (one-time)
|
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{ p: 'core', kind: 'copyTree' },
|
|
13
|
-
{ p: 'bin', kind: 'copyTree' },
|
|
14
|
-
{ p: 'scripts/tools', kind: 'copyTree' },
|
|
15
|
-
{ p: 'scripts/fetch-memory-engine.sh', kind: 'copyFile' },
|
|
16
|
-
{ p: 'scripts/lib.sh', kind: 'copyFile' },
|
|
17
|
-
];
|
|
3
|
+
// Claude Code loads plugins from its own registry (via a marketplace), NOT from
|
|
4
|
+
// an arbitrary project directory — so copying files into the cwd never registers
|
|
5
|
+
// the /draft:* commands. The correct install is the `claude plugin` CLI:
|
|
6
|
+
// claude plugin marketplace add drafthq/draft
|
|
7
|
+
// claude plugin install draft@draft-plugins --scope <user|project>
|
|
8
|
+
// Default scope is `user` (global, available in every project). If the `claude`
|
|
9
|
+
// CLI isn't on PATH, we print the equivalent in-session slash commands.
|
|
10
|
+
const MARKETPLACE_REPO = 'drafthq/draft';
|
|
11
|
+
const PLUGIN_REF = 'draft@draft-plugins'; // name@<marketplace name from marketplace.json>
|
|
18
12
|
|
|
19
13
|
module.exports = {
|
|
20
14
|
id: 'claude-code',
|
|
21
15
|
label: 'Claude Code',
|
|
22
16
|
aliases: ['claude', 'claudecode'],
|
|
23
|
-
defaultScope: '
|
|
17
|
+
defaultScope: 'global',
|
|
24
18
|
|
|
25
19
|
plan(ctx) {
|
|
26
|
-
const
|
|
27
|
-
const actions = ITEMS.map((it) => ({
|
|
28
|
-
kind: it.kind,
|
|
29
|
-
src: asset(it.p),
|
|
30
|
-
dest: path.join(root, it.p),
|
|
31
|
-
label: it.p,
|
|
32
|
-
// Guard on the manifest dir: its presence marks a prior Draft install.
|
|
33
|
-
guard: it.p === '.claude-plugin',
|
|
34
|
-
}));
|
|
35
|
-
|
|
20
|
+
const scope = ctx.scope === 'project' ? 'project' : 'user'; // --global -> user
|
|
36
21
|
return {
|
|
37
|
-
targetSummary:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
targetSummary: `Claude Code plugin registry (scope: ${scope})`,
|
|
23
|
+
requires: 'claude',
|
|
24
|
+
actions: [
|
|
25
|
+
{
|
|
26
|
+
kind: 'exec',
|
|
27
|
+
cmd: 'claude',
|
|
28
|
+
args: ['plugin', 'marketplace', 'add', MARKETPLACE_REPO],
|
|
29
|
+
label: `claude plugin marketplace add ${MARKETPLACE_REPO}`,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
kind: 'exec',
|
|
33
|
+
cmd: 'claude',
|
|
34
|
+
args: ['plugin', 'install', PLUGIN_REF, '--scope', scope],
|
|
35
|
+
label: `claude plugin install ${PLUGIN_REF} --scope ${scope}`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
graph: false, // /draft:init fetches the graph engine on first use
|
|
39
|
+
done: 'Installed draft. Restart Claude Code (or start a new session), then run /draft:init.',
|
|
40
|
+
fallbackTitle: 'Claude Code CLI not found. Run these in Claude Code instead:',
|
|
41
|
+
fallback: [
|
|
42
|
+
'/plugin marketplace add drafthq/draft',
|
|
43
|
+
'/plugin install draft',
|
|
43
44
|
],
|
|
44
45
|
};
|
|
45
46
|
},
|
package/cli/src/installer.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { spawnSync } = require('child_process');
|
|
3
4
|
const fsx = require('./lib/fsx');
|
|
4
5
|
const log = require('./lib/log');
|
|
5
6
|
const { fetchGraph } = require('./lib/graph');
|
|
6
7
|
|
|
8
|
+
function hasBinary(name) {
|
|
9
|
+
// ENOENT on the error means the binary is not on PATH.
|
|
10
|
+
const r = spawnSync(name, ['--version'], { stdio: 'ignore' });
|
|
11
|
+
return !(r.error && r.error.code === 'ENOENT');
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
function execAction(act, ctx) {
|
|
15
|
+
const printable = `${act.cmd} ${act.args.join(' ')}`;
|
|
16
|
+
log.plan(`${ctx.dryRun ? 'would run' : 'running'}: ${printable}`);
|
|
17
|
+
if (ctx.dryRun) return 0;
|
|
18
|
+
const r = spawnSync(act.cmd, act.args, { stdio: 'inherit' });
|
|
19
|
+
if (r.error) {
|
|
20
|
+
log.error(`failed to run ${act.cmd}: ${r.error.message}`);
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
return r.status == null ? 1 : r.status;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function fsAction(act, ctx) {
|
|
8
27
|
log.plan(`${ctx.dryRun ? 'would write' : 'writing'}: ${act.dest}`);
|
|
9
28
|
if (ctx.dryRun) return;
|
|
10
29
|
switch (act.kind) {
|
|
@@ -22,13 +41,28 @@ function execAction(act, ctx) {
|
|
|
22
41
|
}
|
|
23
42
|
}
|
|
24
43
|
|
|
44
|
+
function printFallback(plan) {
|
|
45
|
+
if (plan.fallbackTitle) log.warn(plan.fallbackTitle);
|
|
46
|
+
(plan.fallback || []).forEach((line) => log.info(' ' + line));
|
|
47
|
+
}
|
|
48
|
+
|
|
25
49
|
function install(host, ctx) {
|
|
26
50
|
const plan = host.plan(ctx);
|
|
27
51
|
log.step(`Installing Draft -> ${host.label} [${plan.targetSummary}]${ctx.dryRun ? ' (dry run)' : ''}`);
|
|
28
52
|
|
|
29
|
-
//
|
|
30
|
-
//
|
|
53
|
+
// A plan may require an external CLI (e.g. claude). If it's missing, print
|
|
54
|
+
// the manual fallback and stop — but only when actually installing; a
|
|
55
|
+
// dry run still shows the planned commands.
|
|
56
|
+
if (plan.requires && !ctx.dryRun && !hasBinary(plan.requires)) {
|
|
57
|
+
printFallback(plan);
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Pre-flight: for file copies, every bundled source must exist and guarded
|
|
62
|
+
// targets must not already exist unless --force. Checked up front so a
|
|
63
|
+
// failure writes nothing.
|
|
31
64
|
for (const act of plan.actions) {
|
|
65
|
+
if (act.kind === 'exec') continue;
|
|
32
66
|
if (!fsx.exists(act.src)) {
|
|
33
67
|
log.error(`Bundled asset missing: ${act.src}`);
|
|
34
68
|
log.error('Reinstall @drafthq/draft — the package looks incomplete.');
|
|
@@ -41,7 +75,16 @@ function install(host, ctx) {
|
|
|
41
75
|
}
|
|
42
76
|
|
|
43
77
|
for (const act of plan.actions) {
|
|
44
|
-
|
|
78
|
+
if (act.kind === 'exec') {
|
|
79
|
+
const code = execAction(act, ctx);
|
|
80
|
+
if (code !== 0) {
|
|
81
|
+
log.error(`Step failed (exit ${code}): ${act.label || act.cmd}`);
|
|
82
|
+
if (plan.fallback) printFallback(plan);
|
|
83
|
+
return code;
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
fsAction(act, ctx);
|
|
87
|
+
}
|
|
45
88
|
}
|
|
46
89
|
|
|
47
90
|
if (plan.graph && ctx.graph && !ctx.dryRun) {
|
|
@@ -58,4 +101,4 @@ function install(host, ctx) {
|
|
|
58
101
|
return 0;
|
|
59
102
|
}
|
|
60
103
|
|
|
61
|
-
module.exports = { install };
|
|
104
|
+
module.exports = { install, hasBinary };
|
package/package.json
CHANGED