@refrakt-md/plan 0.9.8 → 0.10.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.
- package/dist/cli-plugin.d.ts.map +1 -1
- package/dist/cli-plugin.js +132 -15
- package/dist/cli-plugin.js.map +1 -1
- package/dist/commands/bundle-behaviors.d.ts +4 -0
- package/dist/commands/bundle-behaviors.d.ts.map +1 -1
- package/dist/commands/bundle-behaviors.js +13 -2
- package/dist/commands/bundle-behaviors.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +5 -3
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/init.d.ts +25 -3
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +296 -98
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/migrate.d.ts +40 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +110 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/project-setup.d.ts +30 -0
- package/dist/commands/project-setup.d.ts.map +1 -0
- package/dist/commands/project-setup.js +123 -0
- package/dist/commands/project-setup.js.map +1 -0
- package/dist/commands/templates.d.ts +0 -22
- package/dist/commands/templates.d.ts.map +1 -1
- package/dist/commands/templates.js +0 -46
- package/dist/commands/templates.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +39 -1
- package/dist/commands/validate.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -12
- package/dist/index.js.map +1 -1
- package/dist/tags/spec.d.ts.map +1 -1
- package/dist/tags/spec.js +2 -1
- package/dist/tags/spec.js.map +1 -1
- package/dist/util.d.ts +5 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +7 -1
- package/dist/util.js.map +1 -1
- package/package.json +20 -8
package/dist/commands/init.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync, readFileSync, appendFileSync } from 'fs';
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, appendFileSync, chmodSync } from 'fs';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
3
4
|
import { runCreate } from './create.js';
|
|
4
|
-
import {
|
|
5
|
+
import { idExists } from './next-id.js';
|
|
6
|
+
import { findInstallRoot, detectPackageManager, installCommand } from './project-setup.js';
|
|
5
7
|
export const EXIT_SUCCESS = 0;
|
|
6
8
|
export const EXIT_ALREADY_EXISTS = 1;
|
|
7
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Tool-specific agent instruction files that get a brief plan summary
|
|
11
|
+
* appended, pointing to plan/INSTRUCTIONS.md for the full reference.
|
|
12
|
+
*/
|
|
8
13
|
export const AGENT_FILES = {
|
|
9
14
|
claude: 'CLAUDE.md',
|
|
10
15
|
cursor: '.cursorrules',
|
|
11
16
|
copilot: '.github/copilot-instructions.md',
|
|
12
17
|
windsurf: '.windsurfrules',
|
|
13
18
|
cline: '.clinerules',
|
|
19
|
+
agents: 'AGENTS.md',
|
|
14
20
|
};
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Brief plan summary appended to agent instruction files.
|
|
23
|
+
* Points to plan/INSTRUCTIONS.md for the full reference.
|
|
24
|
+
*/
|
|
25
|
+
const PLAN_SUMMARY = `\n\n## Plan
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
Project planning lives in \`plan/\` as Markdoc files. Use \`refrakt plan\` commands to manage items — never edit plan files by hand. Run \`refrakt plan next\` to find work. See [plan/INSTRUCTIONS.md](plan/INSTRUCTIONS.md) for the full workflow reference.
|
|
22
28
|
`;
|
|
23
|
-
/**
|
|
29
|
+
/** Markers used to detect that a file already contains our plan section. */
|
|
30
|
+
const PLAN_MARKERS = ['plan/INSTRUCTIONS.md', 'refrakt plan next', 'See [AGENTS.md]'];
|
|
31
|
+
/** Full tool-agnostic workflow guide written to plan/INSTRUCTIONS.md (kept for reference inside plan/). */
|
|
24
32
|
const INSTRUCTIONS_CONTENT = `# Plan — Workflow Guide
|
|
25
33
|
|
|
26
34
|
This directory contains project planning content using the \`@refrakt-md/plan\` runes package. All files are Markdoc (\`.md\` with \`{% %}\` tags).
|
|
@@ -30,7 +38,8 @@ This directory contains project planning content using the \`@refrakt-md/plan\`
|
|
|
30
38
|
\`\`\`
|
|
31
39
|
plan/
|
|
32
40
|
specs/ — Specifications (what to build)
|
|
33
|
-
work/ — Work items
|
|
41
|
+
work/ — Work items (how to build it)
|
|
42
|
+
bugs/ — Bug reports (what is broken)
|
|
34
43
|
decisions/ — Architecture decision records (why it's built this way)
|
|
35
44
|
milestones/ — Named release targets with scope and goals
|
|
36
45
|
\`\`\`
|
|
@@ -83,14 +92,106 @@ refrakt plan create milestone --id v1.0 --title "Description"
|
|
|
83
92
|
- **Bug**: A defect report. Use instead of a work item when something is broken rather than missing.
|
|
84
93
|
- **Decision**: An architectural choice that needs to be recorded for future reference.
|
|
85
94
|
|
|
95
|
+
## Runes in Prose
|
|
96
|
+
|
|
97
|
+
Plan content is text-first, but a curated set of runes may be used inside entity bodies (specs, work items, bugs, decisions, milestones) when they genuinely clarify the prose.
|
|
98
|
+
|
|
99
|
+
- **\`sandbox\`** — embed a small runnable component or layout preview
|
|
100
|
+
- **\`diagram\`** — render a structured diagram (architecture, sequence, state)
|
|
101
|
+
- **\`chart\`** — render a chart from inline data
|
|
102
|
+
- **\`datatable\`** — render a structured data table with search/filter/sort
|
|
103
|
+
- **\`budget\`** — structured monetary budget block (costs, spend allocations)
|
|
104
|
+
|
|
105
|
+
Run \`refrakt reference <name>\` to get the exact Markdoc syntax for any rune (e.g. \`refrakt reference sandbox\`).
|
|
106
|
+
|
|
107
|
+
Prefer prose over runes by default — reach for a rune only when it is meaningfully clearer than plain text or a Markdown table.
|
|
108
|
+
|
|
86
109
|
## JSON Output
|
|
87
110
|
|
|
88
111
|
All commands support \`--format json\` for machine-readable output. This is useful for scripting, CI pipelines, and programmatic integration.
|
|
89
112
|
`;
|
|
90
113
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
114
|
+
* Shell command written into .claude/settings.json SessionStart hook.
|
|
115
|
+
*
|
|
116
|
+
* Detection order mirrors detectPackageManager in project-setup.ts:
|
|
117
|
+
* 1. Corepack `packageManager` field in package.json (authoritative)
|
|
118
|
+
* 2. The most recently modified lockfile (newest mtime wins — handles stale
|
|
119
|
+
* pnpm-lock.yaml / yarn.lock leftovers in an npm-workspaces repo)
|
|
120
|
+
* 3. Default to npm
|
|
93
121
|
*/
|
|
122
|
+
const HOOK_COMMAND = `[ -x node_modules/.bin/refrakt ] || { pm=""; if [ -f package.json ]; then pm=$(sed -n 's/.*"packageManager"[[:space:]]*:[[:space:]]*"\\([a-z]*\\)@.*/\\1/p' package.json | head -n1); fi; case "$pm" in npm|pnpm|yarn|bun) ;; *) pm="" ;; esac; if [ -z "$pm" ]; then newest=""; for f in bun.lockb bun.lock pnpm-lock.yaml yarn.lock package-lock.json; do [ -f "$f" ] || continue; if [ -z "$newest" ] || [ "$f" -nt "$newest" ]; then newest=$f; fi; done; case "$newest" in bun.lock*) pm=bun ;; pnpm-lock.yaml) pm=pnpm ;; yarn.lock) pm=yarn ;; *) pm=npm ;; esac; fi; case "$pm" in bun) bun install ;; pnpm) pnpm install ;; yarn) yarn install ;; *) npm install ;; esac; }`;
|
|
123
|
+
/**
|
|
124
|
+
* Wrapper script body. Works under any POSIX shell with `-nt` support
|
|
125
|
+
* (dash, bash, ksh, zsh, busybox sh). Installs deps on first run using the
|
|
126
|
+
* detected package manager, then defers to `npx refrakt plan`.
|
|
127
|
+
*/
|
|
128
|
+
const WRAPPER_SCRIPT = `#!/usr/bin/env sh
|
|
129
|
+
set -e
|
|
130
|
+
|
|
131
|
+
# Detection order:
|
|
132
|
+
# 1. Corepack packageManager field in package.json (authoritative)
|
|
133
|
+
# 2. Newest lockfile by mtime (so a stale pnpm-lock.yaml next to a fresh
|
|
134
|
+
# package-lock.json correctly resolves to npm)
|
|
135
|
+
# 3. Default to npm
|
|
136
|
+
detect_pm() {
|
|
137
|
+
pm=""
|
|
138
|
+
if [ -f package.json ]; then
|
|
139
|
+
pm=$(sed -n 's/.*"packageManager"[[:space:]]*:[[:space:]]*"\\([a-z]*\\)@.*/\\1/p' package.json | head -n1)
|
|
140
|
+
fi
|
|
141
|
+
case "$pm" in
|
|
142
|
+
npm|pnpm|yarn|bun) echo "$pm"; return ;;
|
|
143
|
+
esac
|
|
144
|
+
newest=""
|
|
145
|
+
for f in bun.lockb bun.lock pnpm-lock.yaml yarn.lock package-lock.json; do
|
|
146
|
+
[ -f "$f" ] || continue
|
|
147
|
+
if [ -z "$newest" ] || [ "$f" -nt "$newest" ]; then
|
|
148
|
+
newest=$f
|
|
149
|
+
fi
|
|
150
|
+
done
|
|
151
|
+
case "$newest" in
|
|
152
|
+
bun.lock*) echo bun ;;
|
|
153
|
+
pnpm-lock.yaml) echo pnpm ;;
|
|
154
|
+
yarn.lock) echo yarn ;;
|
|
155
|
+
*) echo npm ;;
|
|
156
|
+
esac
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if [ ! -x node_modules/.bin/refrakt ]; then
|
|
160
|
+
case "$(detect_pm)" in
|
|
161
|
+
bun) bun install ;;
|
|
162
|
+
pnpm) pnpm install ;;
|
|
163
|
+
yarn) yarn install ;;
|
|
164
|
+
*) npm install ;;
|
|
165
|
+
esac
|
|
166
|
+
fi
|
|
167
|
+
exec npx refrakt plan "$@"
|
|
168
|
+
`;
|
|
169
|
+
/**
|
|
170
|
+
* Read this plan package's own version so we can pin host devDependencies
|
|
171
|
+
* to a range compatible with the CLI that's running init.
|
|
172
|
+
*/
|
|
173
|
+
function getOwnVersion() {
|
|
174
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
175
|
+
// Built: dist/commands/init.js → ../../package.json
|
|
176
|
+
// Source (vitest via tsx): src/commands/init.ts → ../../package.json
|
|
177
|
+
const candidates = [
|
|
178
|
+
join(here, '..', '..', 'package.json'),
|
|
179
|
+
join(here, '..', '..', '..', 'package.json'),
|
|
180
|
+
];
|
|
181
|
+
for (const p of candidates) {
|
|
182
|
+
try {
|
|
183
|
+
const pkg = JSON.parse(readFileSync(p, 'utf-8'));
|
|
184
|
+
if (pkg && pkg.name === '@refrakt-md/plan' && typeof pkg.version === 'string') {
|
|
185
|
+
return pkg.version;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// try next candidate
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return '*';
|
|
193
|
+
}
|
|
194
|
+
/** Detect which agent instruction files already exist in the project root. */
|
|
94
195
|
function detectAgentFiles(projectRoot) {
|
|
95
196
|
const found = [];
|
|
96
197
|
for (const relPath of Object.values(AGENT_FILES)) {
|
|
@@ -100,36 +201,144 @@ function detectAgentFiles(projectRoot) {
|
|
|
100
201
|
}
|
|
101
202
|
return found;
|
|
102
203
|
}
|
|
204
|
+
function hasPlanMarker(content) {
|
|
205
|
+
return PLAN_MARKERS.some(m => content.includes(m));
|
|
206
|
+
}
|
|
103
207
|
/**
|
|
104
|
-
* Append the plan
|
|
208
|
+
* Append the brief plan summary to an agent instruction file.
|
|
105
209
|
* Creates the file (and parent directories) if it doesn't exist.
|
|
106
210
|
* Returns true if the file was updated.
|
|
107
211
|
*/
|
|
108
|
-
function
|
|
212
|
+
function appendPlanSummary(projectRoot, relPath) {
|
|
109
213
|
const filePath = join(projectRoot, relPath);
|
|
110
214
|
if (existsSync(filePath)) {
|
|
111
215
|
const content = readFileSync(filePath, 'utf-8');
|
|
112
|
-
if (
|
|
216
|
+
if (hasPlanMarker(content)) {
|
|
113
217
|
return false;
|
|
114
218
|
}
|
|
115
|
-
appendFileSync(filePath,
|
|
219
|
+
appendFileSync(filePath, PLAN_SUMMARY);
|
|
116
220
|
return true;
|
|
117
221
|
}
|
|
118
222
|
const dir = dirname(filePath);
|
|
119
223
|
if (!existsSync(dir)) {
|
|
120
224
|
mkdirSync(dir, { recursive: true });
|
|
121
225
|
}
|
|
122
|
-
writeFileSync(filePath,
|
|
226
|
+
writeFileSync(filePath, PLAN_SUMMARY.trimStart());
|
|
123
227
|
return true;
|
|
124
228
|
}
|
|
125
229
|
/**
|
|
126
|
-
*
|
|
230
|
+
* Merge plan-related entries into an existing package.json or create one.
|
|
231
|
+
* Never overwrites existing keys. Returns true if the file was modified.
|
|
232
|
+
*/
|
|
233
|
+
function updateHostPackageJson(pkgJsonPath, versions) {
|
|
234
|
+
let pkg = {};
|
|
235
|
+
try {
|
|
236
|
+
pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
let changed = false;
|
|
242
|
+
if (!pkg.scripts || typeof pkg.scripts !== 'object') {
|
|
243
|
+
pkg.scripts = {};
|
|
244
|
+
}
|
|
245
|
+
if (!pkg.scripts.plan) {
|
|
246
|
+
pkg.scripts.plan = 'refrakt plan';
|
|
247
|
+
changed = true;
|
|
248
|
+
}
|
|
249
|
+
if (!pkg.devDependencies || typeof pkg.devDependencies !== 'object') {
|
|
250
|
+
pkg.devDependencies = {};
|
|
251
|
+
}
|
|
252
|
+
const deps = pkg.devDependencies;
|
|
253
|
+
const alreadyInDeps = (name) => (pkg.dependencies && pkg.dependencies[name]) ||
|
|
254
|
+
(pkg.devDependencies && pkg.devDependencies[name]);
|
|
255
|
+
if (!alreadyInDeps('@refrakt-md/cli')) {
|
|
256
|
+
deps['@refrakt-md/cli'] = `^${versions.cli}`;
|
|
257
|
+
changed = true;
|
|
258
|
+
}
|
|
259
|
+
if (!alreadyInDeps('@refrakt-md/plan')) {
|
|
260
|
+
deps['@refrakt-md/plan'] = `^${versions.plan}`;
|
|
261
|
+
changed = true;
|
|
262
|
+
}
|
|
263
|
+
if (changed) {
|
|
264
|
+
writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
265
|
+
}
|
|
266
|
+
return changed;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Write (or merge into) .claude/settings.json with a SessionStart hook that
|
|
270
|
+
* installs dependencies if `refrakt` isn't resolvable. If the file already
|
|
271
|
+
* contains our hook command, leave it alone.
|
|
272
|
+
*/
|
|
273
|
+
function writeClaudeHook(projectRoot) {
|
|
274
|
+
const settingsDir = join(projectRoot, '.claude');
|
|
275
|
+
const settingsPath = join(settingsDir, 'settings.json');
|
|
276
|
+
let settings = {};
|
|
277
|
+
if (existsSync(settingsPath)) {
|
|
278
|
+
try {
|
|
279
|
+
settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (!settings.hooks)
|
|
286
|
+
settings.hooks = {};
|
|
287
|
+
if (!Array.isArray(settings.hooks.SessionStart))
|
|
288
|
+
settings.hooks.SessionStart = [];
|
|
289
|
+
for (const block of settings.hooks.SessionStart) {
|
|
290
|
+
if (!block.hooks)
|
|
291
|
+
continue;
|
|
292
|
+
if (block.hooks.some(h => h.command === HOOK_COMMAND)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
settings.hooks.SessionStart.push({
|
|
297
|
+
hooks: [{ type: 'command', command: HOOK_COMMAND }],
|
|
298
|
+
});
|
|
299
|
+
if (!existsSync(settingsDir)) {
|
|
300
|
+
mkdirSync(settingsDir, { recursive: true });
|
|
301
|
+
}
|
|
302
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Write a ./plan.sh wrapper script and mark it executable. We use `.sh`
|
|
307
|
+
* because the default content directory is also called `plan/` and a file
|
|
308
|
+
* named `plan` can't coexist with a directory of the same name in a single
|
|
309
|
+
* parent. Users run `./plan.sh next` (or just `npm run plan -- next`).
|
|
310
|
+
*/
|
|
311
|
+
function writeWrapperScript(projectRoot) {
|
|
312
|
+
const scriptPath = join(projectRoot, 'plan.sh');
|
|
313
|
+
if (existsSync(scriptPath)) {
|
|
314
|
+
const existing = readFileSync(scriptPath, 'utf-8');
|
|
315
|
+
if (existing === WRAPPER_SCRIPT)
|
|
316
|
+
return false;
|
|
317
|
+
// A different file already exists at ./plan.sh — don't clobber it.
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
writeFileSync(scriptPath, WRAPPER_SCRIPT);
|
|
321
|
+
try {
|
|
322
|
+
chmodSync(scriptPath, 0o755);
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
// Best-effort on platforms without POSIX perms (Windows).
|
|
326
|
+
}
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Initialize a plan directory structure, wire the host project for agent use,
|
|
331
|
+
* and (optionally) install a Claude SessionStart hook + ./plan wrapper.
|
|
127
332
|
*/
|
|
128
333
|
export function runInit(options) {
|
|
129
|
-
const { dir, projectRoot = '.', agent } = options;
|
|
334
|
+
const { dir, projectRoot = '.', agent, noPackageJson = false, noHooks = false, noWrapper = false, } = options;
|
|
335
|
+
const versions = options.versions ?? (() => {
|
|
336
|
+
const v = getOwnVersion();
|
|
337
|
+
return { cli: v, plan: v };
|
|
338
|
+
})();
|
|
130
339
|
const created = [];
|
|
131
|
-
//
|
|
132
|
-
const dirs = ['work', 'specs', 'decisions', 'milestones'];
|
|
340
|
+
// --- 1. plan/ scaffolding ------------------------------------------------
|
|
341
|
+
const dirs = ['work', 'bugs', 'specs', 'decisions', 'milestones'];
|
|
133
342
|
for (const sub of dirs) {
|
|
134
343
|
const path = join(dir, sub);
|
|
135
344
|
if (!existsSync(path)) {
|
|
@@ -137,96 +346,85 @@ export function runInit(options) {
|
|
|
137
346
|
created.push(path + '/');
|
|
138
347
|
}
|
|
139
348
|
}
|
|
140
|
-
// Create example files — use runCreate which generates slug-based filenames
|
|
141
349
|
const examples = [
|
|
142
|
-
{ type: 'spec', id: 'SPEC-001', title: 'Example Spec'
|
|
143
|
-
{ type: 'work', id: 'WORK-001', title: 'Example Work Item',
|
|
144
|
-
{ type: 'decision', id: 'ADR-001', title: 'Example Decision'
|
|
145
|
-
{ type: 'milestone', id: 'v0.1.0', title: 'First Release'
|
|
350
|
+
{ type: 'spec', id: 'SPEC-001', title: 'Example Spec' },
|
|
351
|
+
{ type: 'work', id: 'WORK-001', title: 'Example Work Item', attrs: { priority: 'medium', complexity: 'simple', tags: '' } },
|
|
352
|
+
{ type: 'decision', id: 'ADR-001', title: 'Example Decision' },
|
|
353
|
+
{ type: 'milestone', id: 'v0.1.0', title: 'First Release' },
|
|
146
354
|
];
|
|
147
355
|
for (const ex of examples) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
for (const def of STATUS_PAGES) {
|
|
156
|
-
const slug = `${def.status}.md`;
|
|
157
|
-
const filePath = join(dir, def.typeDir, slug);
|
|
158
|
-
if (!existsSync(filePath)) {
|
|
159
|
-
writeFileSync(filePath, renderStatusPage(def));
|
|
160
|
-
created.push(filePath);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
// Create type-level index pages with links to status filter pages
|
|
164
|
-
const typeDirs = [...new Set(STATUS_PAGES.map(p => p.typeDir))];
|
|
165
|
-
for (const typeDir of typeDirs) {
|
|
166
|
-
const filePath = join(dir, typeDir, 'index.md');
|
|
167
|
-
if (!existsSync(filePath)) {
|
|
168
|
-
writeFileSync(filePath, renderTypeIndexPage(typeDir));
|
|
169
|
-
created.push(filePath);
|
|
170
|
-
}
|
|
356
|
+
// Existing projects commonly already use the IDs we seed (SPEC-001, WORK-001,
|
|
357
|
+
// ADR-001, v0.1.0). Skip the example silently instead of crashing — the
|
|
358
|
+
// user has their own content, they don't need placeholders.
|
|
359
|
+
if (idExists(dir, ex.id))
|
|
360
|
+
continue;
|
|
361
|
+
const result = runCreate({ dir, type: ex.type, id: ex.id, title: ex.title, attrs: ex.attrs });
|
|
362
|
+
created.push(result.file);
|
|
171
363
|
}
|
|
172
|
-
// Create index.md
|
|
173
|
-
const indexFile = join(dir, 'index.md');
|
|
174
|
-
if (!existsSync(indexFile)) {
|
|
175
|
-
writeFileSync(indexFile, `# Project Plan
|
|
176
|
-
|
|
177
|
-
This directory contains project planning content.
|
|
178
|
-
|
|
179
|
-
## Structure
|
|
180
|
-
|
|
181
|
-
- [Specifications](specs/) — What to build
|
|
182
|
-
- [Work Items](work/) — How to build it
|
|
183
|
-
- [Decisions](decisions/) — Why it's built this way
|
|
184
|
-
- [Milestones](milestones/) — Named release targets
|
|
185
|
-
|
|
186
|
-
## Quick Start
|
|
187
|
-
|
|
188
|
-
\`\`\`bash
|
|
189
|
-
refrakt plan next # Find next work item
|
|
190
|
-
refrakt plan status # Project overview
|
|
191
|
-
refrakt plan create work --id WORK-002 --title "My task"
|
|
192
|
-
\`\`\`
|
|
193
|
-
`);
|
|
194
|
-
created.push(indexFile);
|
|
195
|
-
}
|
|
196
|
-
// Create INSTRUCTIONS.md
|
|
197
364
|
const instructionsFile = join(dir, 'INSTRUCTIONS.md');
|
|
198
365
|
if (!existsSync(instructionsFile)) {
|
|
199
366
|
writeFileSync(instructionsFile, INSTRUCTIONS_CONTENT);
|
|
200
367
|
created.push(instructionsFile);
|
|
201
368
|
}
|
|
202
|
-
//
|
|
369
|
+
// --- 2. Append plan summary to agent instruction files ------------------
|
|
203
370
|
const agentFilesUpdated = [];
|
|
204
|
-
if (agent
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// Specific agent requested
|
|
209
|
-
const relPath = AGENT_FILES[agent];
|
|
210
|
-
if (relPath && appendPointer(projectRoot, relPath)) {
|
|
211
|
-
agentFilesUpdated.push(relPath);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
// Auto-detect: append to all existing agent files, fallback to CLAUDE.md
|
|
216
|
-
const existing = detectAgentFiles(projectRoot);
|
|
217
|
-
if (existing.length > 0) {
|
|
218
|
-
for (const relPath of existing) {
|
|
219
|
-
if (appendPointer(projectRoot, relPath)) {
|
|
220
|
-
agentFilesUpdated.push(relPath);
|
|
221
|
-
}
|
|
371
|
+
if (agent !== 'none') {
|
|
372
|
+
const update = (relPath) => {
|
|
373
|
+
if (appendPlanSummary(projectRoot, relPath)) {
|
|
374
|
+
agentFilesUpdated.push(relPath);
|
|
222
375
|
}
|
|
376
|
+
};
|
|
377
|
+
if (agent) {
|
|
378
|
+
const relPath = AGENT_FILES[agent];
|
|
379
|
+
if (relPath)
|
|
380
|
+
update(relPath);
|
|
223
381
|
}
|
|
224
382
|
else {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
383
|
+
const existing = detectAgentFiles(projectRoot);
|
|
384
|
+
for (const relPath of existing)
|
|
385
|
+
update(relPath);
|
|
228
386
|
}
|
|
229
387
|
}
|
|
230
|
-
|
|
388
|
+
// --- 3. Host package.json wiring ---------------------------------------
|
|
389
|
+
const installRootInfo = findInstallRoot(projectRoot);
|
|
390
|
+
const packageManager = installRootInfo ? detectPackageManager(installRootInfo.rootDir) : null;
|
|
391
|
+
let packageJsonUpdated = false;
|
|
392
|
+
if (!noPackageJson && installRootInfo) {
|
|
393
|
+
packageJsonUpdated = updateHostPackageJson(installRootInfo.packageJsonPath, versions);
|
|
394
|
+
}
|
|
395
|
+
// --- 4. Claude SessionStart hook (gated) -------------------------------
|
|
396
|
+
let hookWritten = false;
|
|
397
|
+
const shouldWriteHook = (() => {
|
|
398
|
+
if (noHooks)
|
|
399
|
+
return false;
|
|
400
|
+
if (agent === 'none')
|
|
401
|
+
return false;
|
|
402
|
+
if (agent === 'claude')
|
|
403
|
+
return true;
|
|
404
|
+
if (agent)
|
|
405
|
+
return false; // explicit non-claude agent
|
|
406
|
+
// auto-detect: write if CLAUDE.md exists or was just created
|
|
407
|
+
return existsSync(join(projectRoot, AGENT_FILES.claude));
|
|
408
|
+
})();
|
|
409
|
+
if (shouldWriteHook) {
|
|
410
|
+
hookWritten = writeClaudeHook(projectRoot);
|
|
411
|
+
}
|
|
412
|
+
// --- 5. ./plan.sh wrapper script ---------------------------------------
|
|
413
|
+
let wrapperWritten = false;
|
|
414
|
+
if (!noWrapper && agent !== 'none') {
|
|
415
|
+
wrapperWritten = writeWrapperScript(projectRoot);
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
dir,
|
|
419
|
+
created,
|
|
420
|
+
agentFilesUpdated,
|
|
421
|
+
packageJsonUpdated,
|
|
422
|
+
hookWritten,
|
|
423
|
+
wrapperWritten,
|
|
424
|
+
installRoot: installRootInfo ? installRootInfo.rootDir : null,
|
|
425
|
+
packageManager,
|
|
426
|
+
};
|
|
231
427
|
}
|
|
428
|
+
// Re-export for consumers that want to introspect the install command logic.
|
|
429
|
+
export { installCommand };
|
|
232
430
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACnG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAA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rB,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED,0EAA0E;IAC1E,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,CAAC,SAAS,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACpC,cAAc,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,OAAO;QACN,GAAG;QACH,OAAO;QACP,iBAAiB;QACjB,kBAAkB;QAClB,WAAW;QACX,cAAc;QACd,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;QAC7D,cAAc;KACd,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const EXIT_SUCCESS = 0;
|
|
2
|
+
export declare const EXIT_ERRORS = 1;
|
|
3
|
+
export declare const EXIT_INVALID_ARGS = 2;
|
|
4
|
+
export interface MigrateFilenamesOptions {
|
|
5
|
+
dir: string;
|
|
6
|
+
apply?: boolean;
|
|
7
|
+
useGit?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface PlannedRename {
|
|
10
|
+
id: string;
|
|
11
|
+
from: string;
|
|
12
|
+
to: string;
|
|
13
|
+
}
|
|
14
|
+
export interface MigrateFilenamesError {
|
|
15
|
+
file: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
}
|
|
18
|
+
export interface MigrateFilenamesResult {
|
|
19
|
+
mode: 'dry-run' | 'apply';
|
|
20
|
+
scanned: number;
|
|
21
|
+
planned: PlannedRename[];
|
|
22
|
+
applied: PlannedRename[];
|
|
23
|
+
skipped: {
|
|
24
|
+
milestones: number;
|
|
25
|
+
alreadyCorrect: number;
|
|
26
|
+
};
|
|
27
|
+
errors: MigrateFilenamesError[];
|
|
28
|
+
exitCode: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Scan a plan directory, compute target filenames of the form
|
|
32
|
+
* `{ID}-{slug}.md` for every auto-ID entity, and either preview the
|
|
33
|
+
* renames (dry-run, default) or apply them.
|
|
34
|
+
*
|
|
35
|
+
* Milestones are skipped — they use semver names, not the numeric ID
|
|
36
|
+
* scheme. Files whose current name already matches the target are
|
|
37
|
+
* counted as `alreadyCorrect` and not touched.
|
|
38
|
+
*/
|
|
39
|
+
export declare function runMigrateFilenames(options: MigrateFilenamesOptions): MigrateFilenamesResult;
|
|
40
|
+
//# sourceMappingURL=migrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAKnC,MAAM,WAAW,uBAAuB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,OAAO,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAkF5F"}
|