reladraw 0.23.1 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ That matters here specifically. You can't see the SVG you produced. With auto-la
15
15
 
16
16
  ## Check it is installed, and the same version as this skill
17
17
 
18
- This skill teaches reladraw 0.23.1. Once per session, before the first render, run:
18
+ This skill teaches reladraw 0.24.0. Once per session, before the first render, run:
19
19
 
20
20
  ```
21
21
  reladraw --version
@@ -23,7 +23,7 @@ reladraw --version
23
23
 
24
24
  - **The same:** say nothing.
25
25
  - **Older, or `--version` isn't recognized** (it arrived in 0.17.1): the tool is older than this page and will refuse some of what it teaches. Tell the user, and give them `npm install -g reladraw@latest`.
26
- - **Newer:** this skill is out of date. Tell the user, and give them `reladraw install-skill -g`, which replaces it with the skill that came with their reladraw. Carry on meanwhile; where an error names a replacement spelling, trust the error over this page.
26
+ - **Newer:** this skill is out of date. Tell the user, and give them `reladraw install-skill`, which asks which agents to install for and replaces it with the skill that came with their reladraw. Carry on meanwhile; where an error names a replacement spelling, trust the error over this page.
27
27
 
28
28
  If `reladraw` isn't installed, `npx reladraw` works without installing, and `npm install -g reladraw` installs it.
29
29
 
@@ -1,4 +1,4 @@
1
- # Syntax reference — 0.23.1
1
+ # Syntax reference — 0.24.0
2
2
 
3
3
  What the language accepts. The changelog at the end lists what changed in each published version; 0.17.0's changes are large, and its entry has a table of every old spelling and what to write instead.
4
4
 
@@ -1203,7 +1203,7 @@ reladraw check diagram.reladraw
1203
1203
  | `--no-checks` | print no findings; errors still print |
1204
1204
  | `-v`, `--version` | print the version |
1205
1205
 
1206
- `reladraw install-skill` installs the agent skill that came with this version of reladraw, by running `npx skills add` on it with `--copy`. What follows it goes to `skills`: `-g` to install for every project, `-a claude-code` for one agent.
1206
+ `reladraw install-skill` installs the agent skill that came with this version of reladraw, for every project, by running `npx skills add` on it with `--copy`. `--claude` installs it in `~/.claude/skills`, `--agents` in `~/.agents/skills` (Codex and others), and both may be given; with neither, it asks, or, with no terminal to ask in, refuses and names them. For any other agent it prints the `skills` command to run.
1207
1207
 
1208
1208
  The output is a standalone SVG: every picture is drawn into it as path data, never from a font or a linked file. A web page can draw a diagram in place with `<reladraw-diagram>`; see "In a web page" in the README.
1209
1209
 
@@ -1338,6 +1338,10 @@ Designed and absent from the code.
1338
1338
 
1339
1339
  Pre-1.0, so the minor number is where a breaking change goes. Every removal is refused by name with the replacement quoted, rather than dropped in silence: an older file stops with an error saying what to write instead.
1340
1340
 
1341
+ **0.24.0**
1342
+
1343
+ - **`reladraw install-skill` installs for Claude Code, the `~/.agents` folder, or both, and asks which.** It used to pass everything on to `skills`, which, given no agent, put a copy in the folder of every agent it knows, more than fifty of them, and in the current project unless `-g` was written. It now always installs for every project, in the places `--claude` and `--agents` name; `-a` and the other `skills` options are refused with the `skills` command that does the same, and `-g` is still accepted.
1344
+
1341
1345
  **0.23.1**
1342
1346
 
1343
1347
  - **`reladraw format` no longer fails on a comment between a placement and its bracket**, such as `right of a`, then `// why wide`, then `(gap: wide)` on lines of their own. It stopped with "Cannot read properties of undefined"; it now keeps the comment where it was. Reported in #22.
package/README.md CHANGED
@@ -77,22 +77,24 @@ Each `<reladraw-diagram>` is replaced by its SVG. Indent the source however suit
77
77
  To install a skill to let your agent know how to use reladraw:
78
78
 
79
79
  ```
80
- reladraw install-skill -g
80
+ reladraw install-skill
81
81
  ```
82
82
 
83
- That installs the skill that came with your copy of reladraw, so it teaches what your reladraw accepts, for every agent you use (Claude Code, Codex, Cursor, Copilot and others), each in its own skills directory. It hands the work to [skills](https://www.npmjs.com/package/skills), and passes on whatever you write after `install-skill`. Leave off `-g` to install it into the current project only. To install it for just one agent, name it with `-a`:
83
+ That installs the skill that came with your copy of reladraw, so it teaches what your reladraw accepts, for every project. It asks where: `~/.claude/skills` for Claude Code, `~/.agents/skills` for Codex and the other agents that read it, or both. To say so without being asked, as when an agent runs it, write `--claude`, `--agents`, or both:
84
84
 
85
85
  ```
86
- reladraw install-skill -g -a claude-code
86
+ reladraw install-skill --claude --agents
87
87
  ```
88
88
 
89
+ For any other agent, it prints the [skills](https://www.npmjs.com/package/skills) command that installs this same skill there.
90
+
89
91
  The skill is a copy, so after upgrading reladraw, run the command again to bring the skill up to date with it.
90
92
 
91
93
  To install the skill from the main branch instead, which can run ahead of the release on npm, run `npx skills add reladraw/reladraw -g`.
92
94
 
93
95
  ## Status
94
96
 
95
- Version 0.23.1. Early stage, but works. The parser, layout engine, and SVG renderer are written in TypeScript, with zero runtime dependencies. There is a command-line tool that turns a .reladraw text file into an SVG, and an element that does the same inside a web page.
97
+ Version 0.24.0. Early stage, but works. The parser, layout engine, and SVG renderer are written in TypeScript, with zero runtime dependencies. There is a command-line tool that turns a .reladraw text file into an SVG, and an element that does the same inside a web page.
96
98
 
97
99
  ## License
98
100
 
package/SYNTAX.md CHANGED
@@ -1,4 +1,4 @@
1
- # Syntax reference — 0.23.1
1
+ # Syntax reference — 0.24.0
2
2
 
3
3
  What the language accepts. The changelog at the end lists what changed in each published version; 0.17.0's changes are large, and its entry has a table of every old spelling and what to write instead.
4
4
 
@@ -1203,7 +1203,7 @@ reladraw check diagram.reladraw
1203
1203
  | `--no-checks` | print no findings; errors still print |
1204
1204
  | `-v`, `--version` | print the version |
1205
1205
 
1206
- `reladraw install-skill` installs the agent skill that came with this version of reladraw, by running `npx skills add` on it with `--copy`. What follows it goes to `skills`: `-g` to install for every project, `-a claude-code` for one agent.
1206
+ `reladraw install-skill` installs the agent skill that came with this version of reladraw, for every project, by running `npx skills add` on it with `--copy`. `--claude` installs it in `~/.claude/skills`, `--agents` in `~/.agents/skills` (Codex and others), and both may be given; with neither, it asks, or, with no terminal to ask in, refuses and names them. For any other agent it prints the `skills` command to run.
1207
1207
 
1208
1208
  The output is a standalone SVG: every picture is drawn into it as path data, never from a font or a linked file. A web page can draw a diagram in place with `<reladraw-diagram>`; see "In a web page" in the README.
1209
1209
 
@@ -1338,6 +1338,10 @@ Designed and absent from the code.
1338
1338
 
1339
1339
  Pre-1.0, so the minor number is where a breaking change goes. Every removal is refused by name with the replacement quoted, rather than dropped in silence: an older file stops with an error saying what to write instead.
1340
1340
 
1341
+ **0.24.0**
1342
+
1343
+ - **`reladraw install-skill` installs for Claude Code, the `~/.agents` folder, or both, and asks which.** It used to pass everything on to `skills`, which, given no agent, put a copy in the folder of every agent it knows, more than fifty of them, and in the current project unless `-g` was written. It now always installs for every project, in the places `--claude` and `--agents` name; `-a` and the other `skills` options are refused with the `skills` command that does the same, and `-g` is still accepted.
1344
+
1341
1345
  **0.23.1**
1342
1346
 
1343
1347
  - **`reladraw format` no longer fails on a comment between a placement and its bracket**, such as `right of a`, then `// why wide`, then `(gap: wide)` on lines of their own. It stopped with "Cannot read properties of undefined"; it now keeps the comment where it was. Reported in #22.
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ const USAGE = `reladraw — draw a diagram from stated placement
19
19
  reladraw format <input.reladraw>... [--check]
20
20
  reladraw format - [--check]
21
21
  reladraw format --init
22
- reladraw install-skill [skills options]
22
+ reladraw install-skill [--claude] [--agents]
23
23
 
24
24
  render draw the diagram to an SVG, and print any findings: places
25
25
  where the picture, drawn as written, may not read as meant.
@@ -37,9 +37,10 @@ const USAGE = `reladraw — draw a diagram from stated placement
37
37
  default with what it does.
38
38
  install-skill
39
39
  install the agent skill that came with this version of
40
- reladraw, so it teaches what this tool accepts. It runs
41
- npx skills add with --copy, and passes on what follows:
42
- -g for every project, -a claude-code for one agent.
40
+ reladraw, so it teaches what this tool accepts, for every
41
+ project: --claude in ~/.claude/skills, --agents in
42
+ ~/.agents/skills (Codex and others), or both. With neither,
43
+ it asks.
43
44
 
44
45
  -o, --out where render writes the SVG. Defaults to the input path with
45
46
  its extension replaced by .svg. Use - for standard output.
@@ -62,17 +63,113 @@ const USAGE = `reladraw — draw a diagram from stated placement
62
63
  const COMMANDS = ['render', 'check', 'format', 'install-skill'];
63
64
  // The version of skills this was tried with, so a change there can't break it.
64
65
  const SKILLS_PACKAGE = 'skills@1.7.6';
66
+ // The two places the skill is installed, each picked by its flag. skills
67
+ // knows a folder by an agent that reads it: ~/.agents/skills is its "codex",
68
+ // and other agents read it too. Left to itself, skills installs for every
69
+ // agent it knows of, more than fifty, so the agents are always named.
70
+ const SKILL_TARGETS = [
71
+ { flag: '--claude', agent: 'claude-code', label: 'Claude Code', dir: '~/.claude/skills' },
72
+ { flag: '--agents', agent: 'codex', label: 'Codex and others', dir: '~/.agents/skills' },
73
+ ];
74
+ function ownVersion() {
75
+ // package.json ships beside dist/, so the number is the installed one.
76
+ return JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
77
+ }
78
+ // For any other agent, or a single project, skills is run by hand on this
79
+ // install's skill, so it still matches this reladraw.
80
+ function skillsCommand(skills, agent = '<agent>') {
81
+ const path = /\s/.test(skills) ? JSON.stringify(skills) : skills;
82
+ return `npx ${SKILLS_PACKAGE} add ${path} --copy -g -a ${agent}`;
83
+ }
84
+ const NAME_THE_TARGETS = SKILL_TARGETS.map((t) => `${t.flag} (${t.dir}, for ${t.label})`).join(', ') + ', or both';
85
+ // In a terminal, a bare install-skill asks; otherwise, as when an agent runs
86
+ // it, the flags must say, because there is no one to ask.
87
+ async function askTargets(skills) {
88
+ const { createInterface } = await import('node:readline/promises');
89
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
90
+ const closed = new Promise((done) => rl.once('close', () => done(undefined)));
91
+ const both = SKILL_TARGETS.length + 1;
92
+ process.stdout.write(`Install the reladraw ${ownVersion()} skill for which agents?\n` +
93
+ SKILL_TARGETS.map((t, i) => ` ${i + 1} ${t.label.padEnd(17)} ${t.dir}\n`).join('') +
94
+ ` ${both} both\n ${both + 1} another agent\n`);
95
+ try {
96
+ for (;;) {
97
+ const answer = await Promise.race([rl.question(`Choose [${both}]: `), closed]);
98
+ if (answer === undefined) {
99
+ process.stdout.write('\n');
100
+ return undefined;
101
+ }
102
+ const n = Number(answer.trim() || both);
103
+ if (n >= 1 && n <= SKILL_TARGETS.length)
104
+ return [SKILL_TARGETS[n - 1].agent];
105
+ if (n === both)
106
+ return SKILL_TARGETS.map((t) => t.agent);
107
+ if (n === both + 1)
108
+ return 'other';
109
+ process.stdout.write(`Type a number from 1 to ${both + 1}.\n`);
110
+ }
111
+ }
112
+ finally {
113
+ rl.close();
114
+ }
115
+ }
65
116
  // The skill ships in the package beside dist/, as the one in the repository.
66
- // skills does the work of knowing where each agent keeps its skills; --copy
67
- // because an npx run leaves the package in a cache, where a link would break.
68
- function installSkill(args) {
117
+ // skills does the work of copying it in; --copy because an npx run leaves the
118
+ // package in a cache, where a link would break.
119
+ async function installSkill(args) {
69
120
  const skills = fileURLToPath(new URL('../.claude/skills/', import.meta.url));
70
121
  if (!existsSync(skills)) {
71
122
  process.stderr.write(`reladraw: the skill isn't in this install of reladraw (looked in ${skills})\n`);
72
123
  return 1;
73
124
  }
125
+ let agents = [];
126
+ for (let i = 0; i < args.length; i++) {
127
+ const arg = args[i];
128
+ const target = SKILL_TARGETS.find((t) => t.flag === arg);
129
+ if (target) {
130
+ if (!agents.includes(target.agent))
131
+ agents.push(target.agent);
132
+ }
133
+ else if (arg === '-g' || arg === '--global') {
134
+ // Always global now; skills from before 0.24 tell the user to write -g.
135
+ }
136
+ else if (arg === '-h' || arg === '--help') {
137
+ process.stdout.write(`reladraw install-skill [--claude] [--agents]\n\n` +
138
+ `Installs the skill that came with reladraw ${ownVersion()}, for every project:\n` +
139
+ SKILL_TARGETS.map((t) => ` ${t.flag.padEnd(9)} ${t.dir}, for ${t.label}\n`).join('') +
140
+ `With neither, it asks. For another agent, run:\n ${skillsCommand(skills)}\n`);
141
+ return 0;
142
+ }
143
+ else if (arg === '-a' || arg === '--agent') {
144
+ const agent = args[i + 1];
145
+ process.stderr.write(`reladraw: install-skill takes ${NAME_THE_TARGETS}, not -a. ` +
146
+ `For ${agent ? `the agent ${agent}` : 'another agent'}, run:\n ${skillsCommand(skills, agent)}\n`);
147
+ return 1;
148
+ }
149
+ else {
150
+ process.stderr.write(`reladraw: install-skill doesn't take ${arg}; it takes ${NAME_THE_TARGETS}. ` +
151
+ `For another agent, run:\n ${skillsCommand(skills)}\n`);
152
+ return 1;
153
+ }
154
+ }
155
+ if (agents.length === 0) {
156
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
157
+ process.stderr.write(`reladraw: say which agents to install the skill for: ${NAME_THE_TARGETS}. ` +
158
+ `For another agent, run:\n ${skillsCommand(skills)}\n`);
159
+ return 1;
160
+ }
161
+ const picked = await askTargets(skills);
162
+ if (picked === undefined)
163
+ return 1;
164
+ if (picked === 'other') {
165
+ process.stdout.write(`For another agent, run this, with its name from skills' list:\n ${skillsCommand(skills)}\n`);
166
+ return 0;
167
+ }
168
+ agents = picked;
169
+ }
74
170
  const windows = process.platform === 'win32';
75
- const command = [SKILLS_PACKAGE, 'add', skills, '--copy', ...args];
171
+ // -y because the choice is already made; skills would otherwise ask again.
172
+ const command = [SKILLS_PACKAGE, 'add', skills, '--copy', '-g', '-y', '-a', ...agents];
76
173
  // On Windows npx is a .cmd, which Node runs only through a shell.
77
174
  const result = spawnSync(windows ? 'npx.cmd' : 'npx', windows ? command.map((a) => `"${a}"`) : command, {
78
175
  stdio: 'inherit',
@@ -85,7 +182,7 @@ function installSkill(args) {
85
182
  return result.status ?? 1;
86
183
  }
87
184
  async function main(argv) {
88
- // Everything after install-skill is for skills, -h and -v included.
185
+ // install-skill reads its own flags, -h included.
89
186
  if (argv[0] === 'install-skill')
90
187
  return installSkill(argv.slice(1));
91
188
  if (argv.length === 0 || argv.includes('-h') || argv.includes('--help')) {
@@ -93,9 +190,7 @@ async function main(argv) {
93
190
  return argv.length === 0 ? 1 : 0;
94
191
  }
95
192
  if (argv.includes('-v') || argv.includes('--version')) {
96
- // package.json ships beside dist/, so the number is the installed one.
97
- const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
98
- process.stdout.write(`${pkg.version}\n`);
193
+ process.stdout.write(`${ownVersion()}\n`);
99
194
  return 0;
100
195
  }
101
196
  const verb = argv[0];
@@ -420,7 +515,7 @@ function nearestSettings(folder, found) {
420
515
  // The exit code is set, not exited with: process.exit ends the process at
421
516
  // once, and a write to a pipe that hasn't drained yet is lost, which cut
422
517
  // `format -` and `render -o -` off at 64 KB. Node exits on its own once the
423
- // output is written. `./dev.sh pipe` checks it.
518
+ // output is written.
424
519
  main(process.argv.slice(2)).then((code) => {
425
520
  process.exitCode = code;
426
521
  }, (error) => {
@@ -93,7 +93,7 @@ export declare const DEFAULT_FONT_SIZE = 14;
93
93
  * `small` is sampled rather than chosen. In
94
94
  * `examples/reference/arch.png` the box and container texts run 25
95
95
  * pixels baseline to baseline and every annotation runs 21, which is this
96
- * ratio; `./dev.sh textrows` is how that was read off. `large` is the same step
96
+ * ratio. `large` is the same step
97
97
  * taken the other way, so the scale is symmetric about the document size.
98
98
  */
99
99
  export declare const TEXT_SIZES: Record<string, number>;
package/dist/constants.js CHANGED
@@ -111,7 +111,7 @@ export const DEFAULT_FONT_SIZE = 14;
111
111
  * `small` is sampled rather than chosen. In
112
112
  * `examples/reference/arch.png` the box and container texts run 25
113
113
  * pixels baseline to baseline and every annotation runs 21, which is this
114
- * ratio; `./dev.sh textrows` is how that was read off. `large` is the same step
114
+ * ratio. `large` is the same step
115
115
  * taken the other way, so the scale is symmetric about the document size.
116
116
  */
117
117
  export const TEXT_SIZES = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reladraw",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "description": "A diagram language where you say where things go.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,7 +35,6 @@
35
35
  "scripts": {
36
36
  "build": "tsc && tsc -p tsconfig.element.json",
37
37
  "prepublishOnly": "npm run build",
38
- "preversion": "./dev.sh check-version \"$npm_new_version\"",
39
38
  "dev": "tsc --watch",
40
39
  "example": "npm run build && node dist/cli.js render examples/arch.reladraw -o examples/out/arch.svg"
41
40
  },