@drafthq/draft 2.7.0 → 2.8.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 +11 -9
- package/cli/src/hosts/claude-code.js +54 -32
- package/cli/src/hosts/codex.js +1 -1
- package/cli/src/hosts/opencode.js +1 -1
- package/cli/src/installer.js +47 -4
- package/package.json +1 -1
- package/scripts/fetch-memory-engine.sh +2 -2
|
@@ -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.
|
|
15
|
+
"version": "2.8.0",
|
|
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)
|
|
@@ -157,7 +159,7 @@ curl -o .gemini.md https://raw.githubusercontent.com/drafthq/draft/main/integrat
|
|
|
157
159
|
|
|
158
160
|
## Built-in Code Intelligence
|
|
159
161
|
|
|
160
|
-
Draft is powered by a **local knowledge graph engine** ([codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)) that gives every command precise structural context — module boundaries, call graphs, dependencies, hotspots. It's 100% local (no API key, no SaaS),
|
|
162
|
+
Draft is powered by a **local knowledge graph engine** ([codebase-memory-mcp](https://github.com/DeusData/codebase-memory-mcp)) that gives every command precise structural context — module boundaries, call graphs, dependencies, hotspots. It's 100% local (no API key, no SaaS), fetched during `draft install` (best-effort; `--no-graph` to skip), with first-use fetch as a fallback.
|
|
161
163
|
|
|
162
164
|
```bash
|
|
163
165
|
/draft:graph # build / refresh the snapshot
|
|
@@ -1,45 +1,67 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
//
|
|
7
|
+
// We run four idempotent steps so a re-run UPGRADES an existing install rather
|
|
8
|
+
// than no-op'ing on "already installed":
|
|
9
|
+
// 1. marketplace add <repo> — register the marketplace (no-op if present)
|
|
10
|
+
// 2. marketplace update <name> — re-fetch manifest from GitHub (the upgrade key)
|
|
11
|
+
// 3. plugin install <ref> — install (no-op if already installed)
|
|
12
|
+
// 4. plugin update <ref> — bump an existing install to the new version
|
|
13
|
+
// Steps 2 and 4 exit 0 when there's nothing to do, so they're safe on a fresh
|
|
14
|
+
// install too. Default scope is `user` (global). If the `claude` CLI isn't on
|
|
15
|
+
// PATH, we print the equivalent in-session slash commands.
|
|
16
|
+
const MARKETPLACE_REPO = 'drafthq/draft';
|
|
17
|
+
const MARKETPLACE_NAME = 'draft-plugins'; // the `name` field in .claude-plugin/marketplace.json
|
|
18
|
+
const PLUGIN_REF = `draft@${MARKETPLACE_NAME}`; // name@<marketplace name>
|
|
18
19
|
|
|
19
20
|
module.exports = {
|
|
20
21
|
id: 'claude-code',
|
|
21
22
|
label: 'Claude Code',
|
|
22
23
|
aliases: ['claude', 'claudecode'],
|
|
23
|
-
defaultScope: '
|
|
24
|
+
defaultScope: 'global',
|
|
24
25
|
|
|
25
26
|
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
|
-
|
|
27
|
+
const scope = ctx.scope === 'project' ? 'project' : 'user'; // --global -> user
|
|
36
28
|
return {
|
|
37
|
-
targetSummary:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
targetSummary: `Claude Code plugin registry (scope: ${scope})`,
|
|
30
|
+
requires: 'claude',
|
|
31
|
+
actions: [
|
|
32
|
+
{
|
|
33
|
+
kind: 'exec',
|
|
34
|
+
cmd: 'claude',
|
|
35
|
+
args: ['plugin', 'marketplace', 'add', MARKETPLACE_REPO],
|
|
36
|
+
label: `claude plugin marketplace add ${MARKETPLACE_REPO}`,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
kind: 'exec',
|
|
40
|
+
cmd: 'claude',
|
|
41
|
+
args: ['plugin', 'marketplace', 'update', MARKETPLACE_NAME],
|
|
42
|
+
label: `claude plugin marketplace update ${MARKETPLACE_NAME}`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
kind: 'exec',
|
|
46
|
+
cmd: 'claude',
|
|
47
|
+
args: ['plugin', 'install', PLUGIN_REF, '--scope', scope],
|
|
48
|
+
label: `claude plugin install ${PLUGIN_REF} --scope ${scope}`,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
kind: 'exec',
|
|
52
|
+
cmd: 'claude',
|
|
53
|
+
args: ['plugin', 'update', PLUGIN_REF, '--scope', scope],
|
|
54
|
+
label: `claude plugin update ${PLUGIN_REF} --scope ${scope}`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
graph: true, // fetch the graph engine at install time (/draft:init also fetches on first use as a fallback)
|
|
58
|
+
done: 'Installed/updated draft. Restart Claude Code (or start a new session), then run /draft:init.',
|
|
59
|
+
fallbackTitle: 'Claude Code CLI not found. Run these in Claude Code instead:',
|
|
60
|
+
fallback: [
|
|
61
|
+
'/plugin marketplace add drafthq/draft',
|
|
62
|
+
'/plugin marketplace update draft-plugins',
|
|
63
|
+
'/plugin install draft',
|
|
64
|
+
'/plugin update draft',
|
|
43
65
|
],
|
|
44
66
|
};
|
|
45
67
|
},
|
package/cli/src/hosts/codex.js
CHANGED
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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# which scripts/tools/_lib.sh:find_memory_bin resolves.
|
|
9
9
|
#
|
|
10
10
|
# Pinned by default for reproducibility; override with CMM_VERSION (a tag, e.g.
|
|
11
|
-
# "v0.
|
|
11
|
+
# "v0.8.1", or "latest").
|
|
12
12
|
#
|
|
13
13
|
# Usage:
|
|
14
14
|
# scripts/fetch-memory-engine.sh [--dest DIR] [--force]
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
set -euo pipefail
|
|
22
22
|
|
|
23
23
|
REPO="DeusData/codebase-memory-mcp"
|
|
24
|
-
DEFAULT_VERSION="v0.
|
|
24
|
+
DEFAULT_VERSION="v0.8.1" # pinned; bump deliberately. NOTE: tag must carry the leading "v" AND have published assets (0.7.0 had none → 404).
|
|
25
25
|
VERSION="${CMM_VERSION:-$DEFAULT_VERSION}"
|
|
26
26
|
DEST="$HOME/.cache/draft/bin"
|
|
27
27
|
FORCE=0
|