@refrakt-md/plan 0.9.7 → 0.9.9
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 +55 -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/init.d.ts +27 -3
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +341 -43
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/project-setup.d.ts +24 -0
- package/dist/commands/project-setup.d.ts.map +1 -0
- package/dist/commands/project-setup.js +79 -0
- package/dist/commands/project-setup.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -11
- package/dist/index.js.map +1 -1
- package/dist/render.d.ts +31 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +57 -0
- package/dist/render.js.map +1 -0
- 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,10 +1,15 @@
|
|
|
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
5
|
import { STATUS_PAGES, renderStatusPage, renderTypeIndexPage } from './templates.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. These get a short pointer to AGENTS.md.
|
|
11
|
+
* AGENTS.md itself is the canonical file — full workflow content lives there.
|
|
12
|
+
*/
|
|
8
13
|
export const AGENT_FILES = {
|
|
9
14
|
claude: 'CLAUDE.md',
|
|
10
15
|
cursor: '.cursorrules',
|
|
@@ -12,15 +17,94 @@ export const AGENT_FILES = {
|
|
|
12
17
|
windsurf: '.windsurfrules',
|
|
13
18
|
cline: '.clinerules',
|
|
14
19
|
};
|
|
15
|
-
/**
|
|
16
|
-
const
|
|
17
|
-
|
|
20
|
+
/** Absolute-ish path to the canonical agent instructions file. */
|
|
21
|
+
export const AGENTS_FILE = 'AGENTS.md';
|
|
22
|
+
/** Single pointer line written into tool-specific instruction files. */
|
|
23
|
+
const POINTER_LINE = `\n\nSee [AGENTS.md](./AGENTS.md) for agent instructions, including the plan workflow.\n`;
|
|
24
|
+
/** Marker used to detect that a tool-specific file already contains our pointer. */
|
|
25
|
+
const POINTER_MARKER = 'See [AGENTS.md]';
|
|
26
|
+
/** Legacy marker (pre-AGENTS.md migration) — still recognised to avoid duplicate appends. */
|
|
27
|
+
const LEGACY_POINTER_MARKERS = ['plan/INSTRUCTIONS.md', 'refrakt plan next'];
|
|
28
|
+
/** Full agent-facing workflow written to AGENTS.md. */
|
|
29
|
+
const AGENTS_MD_CONTENT = `# Agent Instructions
|
|
30
|
+
|
|
31
|
+
This file is the canonical reference for AI coding agents working in this repository. It is read by Claude Code, Cursor, Aider, Codex, Continue, Zed, and other tools that follow the AGENTS.md convention. Tool-specific files (\`CLAUDE.md\`, \`.cursorrules\`, etc.) should be short pointers back here.
|
|
32
|
+
|
|
33
|
+
## Before you start
|
|
34
|
+
|
|
35
|
+
Run \`npm run plan -- status\` (or \`./plan status\` if the wrapper script is present). If it fails with "command not found" or a module resolution error, run your package manager's install command (\`npm install\`, \`pnpm install\`, \`yarn\`, or \`bun install\`) and retry.
|
|
36
|
+
|
|
37
|
+
**Never edit files under \`plan/\` by hand.** Always use \`refrakt plan\` commands — they keep IDs, statuses, and cross-references consistent. Manual edits will be silently overwritten by later commands.
|
|
38
|
+
|
|
39
|
+
## Plan — Workflow Guide
|
|
40
|
+
|
|
41
|
+
Project planning content lives in \`plan/\` as Markdoc files using the \`@refrakt-md/plan\` runes package.
|
|
42
|
+
|
|
43
|
+
### Directory Layout
|
|
44
|
+
|
|
45
|
+
\`\`\`
|
|
46
|
+
plan/
|
|
47
|
+
specs/ — Specifications (what to build)
|
|
48
|
+
work/ — Work items and bugs (how to build it)
|
|
49
|
+
decisions/ — Architecture decision records (why it's built this way)
|
|
50
|
+
milestones/ — Named release targets with scope and goals
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
### Workflow
|
|
54
|
+
|
|
55
|
+
1. Find next work item: \`refrakt plan next\`
|
|
56
|
+
2. Start working: \`refrakt plan update <id> --status in-progress\`
|
|
57
|
+
3. Read referenced specs and decisions before implementing
|
|
58
|
+
4. Check off criteria: \`refrakt plan update <id> --check "criterion text"\`
|
|
59
|
+
5. Mark complete with resolution: \`refrakt plan update <id> --status done --resolve "summary of what was done"\`
|
|
60
|
+
6. Check project status: \`refrakt plan status\`
|
|
61
|
+
|
|
62
|
+
When marking a work item done, always provide a \`--resolve\` summary unless the change is trivial. This captures implementation context (files changed, decisions made, branch/PR) for future reference.
|
|
63
|
+
|
|
64
|
+
### ID Conventions
|
|
65
|
+
|
|
66
|
+
| Type | Prefix | Example |
|
|
67
|
+
|------|--------|---------|
|
|
68
|
+
| Spec | \`SPEC-\` | \`SPEC-023\` |
|
|
69
|
+
| Work | \`WORK-\` | \`WORK-051\` |
|
|
70
|
+
| Decision | \`ADR-\` | \`ADR-005\` |
|
|
71
|
+
| Bug | \`BUG-\` | \`BUG-001\` |
|
|
72
|
+
| Milestone | \`v\`+semver | \`v1.0.0\` |
|
|
73
|
+
|
|
74
|
+
IDs are auto-assigned when you omit \`--id\` from \`refrakt plan create\`.
|
|
75
|
+
|
|
76
|
+
### Valid Statuses
|
|
77
|
+
|
|
78
|
+
- **spec**: \`draft\` → \`review\` → \`accepted\` → \`superseded\` | \`deprecated\`
|
|
79
|
+
- **work**: \`draft\` → \`ready\` → \`in-progress\` → \`review\` → \`done\` (also: \`blocked\`)
|
|
80
|
+
- **bug**: \`reported\` → \`confirmed\` → \`in-progress\` → \`fixed\` (also: \`wontfix\`, \`duplicate\`)
|
|
81
|
+
- **decision**: \`proposed\` → \`accepted\` → \`superseded\` | \`deprecated\`
|
|
82
|
+
- **milestone**: \`planning\` → \`active\` → \`complete\`
|
|
83
|
+
|
|
84
|
+
### Creating Items
|
|
85
|
+
|
|
86
|
+
\`\`\`bash
|
|
87
|
+
refrakt plan create work --title "Description"
|
|
88
|
+
refrakt plan create bug --title "Description"
|
|
89
|
+
refrakt plan create spec --title "Description"
|
|
90
|
+
refrakt plan create decision --title "Description"
|
|
91
|
+
refrakt plan create milestone --id v1.0 --title "Description"
|
|
92
|
+
\`\`\`
|
|
93
|
+
|
|
94
|
+
### When to Create Each Type
|
|
95
|
+
|
|
96
|
+
- **Spec**: A new feature idea, design proposal, or system description. Source of truth for *what* to build.
|
|
97
|
+
- **Work item**: A discrete, implementable piece of work with acceptance criteria.
|
|
98
|
+
- **Bug**: A defect report. Use instead of a work item when something is broken rather than missing.
|
|
99
|
+
- **Decision**: An architectural choice that needs to be recorded for future reference.
|
|
18
100
|
|
|
19
|
-
|
|
101
|
+
### JSON Output
|
|
20
102
|
|
|
21
|
-
|
|
103
|
+
All commands support \`--format json\` for machine-readable output. This is useful for scripting, CI pipelines, and programmatic integration.
|
|
104
|
+
|
|
105
|
+
See \`plan/INSTRUCTIONS.md\` for an in-tree copy of this workflow, kept alongside the content for convenience.
|
|
22
106
|
`;
|
|
23
|
-
/** Full tool-agnostic workflow guide written to plan/INSTRUCTIONS.md. */
|
|
107
|
+
/** Full tool-agnostic workflow guide written to plan/INSTRUCTIONS.md (kept for reference inside plan/). */
|
|
24
108
|
const INSTRUCTIONS_CONTENT = `# Plan — Workflow Guide
|
|
25
109
|
|
|
26
110
|
This directory contains project planning content using the \`@refrakt-md/plan\` runes package. All files are Markdoc (\`.md\` with \`{% %}\` tags).
|
|
@@ -88,9 +172,56 @@ refrakt plan create milestone --id v1.0 --title "Description"
|
|
|
88
172
|
All commands support \`--format json\` for machine-readable output. This is useful for scripting, CI pipelines, and programmatic integration.
|
|
89
173
|
`;
|
|
90
174
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
175
|
+
* Shell command written into .claude/settings.json SessionStart hook.
|
|
176
|
+
* Detects the package manager at execution time from lockfiles, so users can
|
|
177
|
+
* switch package managers without re-running init.
|
|
178
|
+
*/
|
|
179
|
+
const HOOK_COMMAND = `[ -x node_modules/.bin/refrakt ] || { if [ -f bun.lockb ] || [ -f bun.lock ]; then bun install; elif [ -f pnpm-lock.yaml ]; then pnpm install; elif [ -f yarn.lock ]; then yarn install; else npm install; fi; }`;
|
|
180
|
+
/**
|
|
181
|
+
* Wrapper script body. Works under any POSIX shell; installs deps on first
|
|
182
|
+
* run using the detected package manager, then defers to `npx refrakt plan`.
|
|
183
|
+
*/
|
|
184
|
+
const WRAPPER_SCRIPT = `#!/usr/bin/env sh
|
|
185
|
+
set -e
|
|
186
|
+
if [ ! -x node_modules/.bin/refrakt ]; then
|
|
187
|
+
if [ -f bun.lockb ] || [ -f bun.lock ]; then
|
|
188
|
+
bun install
|
|
189
|
+
elif [ -f pnpm-lock.yaml ]; then
|
|
190
|
+
pnpm install
|
|
191
|
+
elif [ -f yarn.lock ]; then
|
|
192
|
+
yarn install
|
|
193
|
+
else
|
|
194
|
+
npm install
|
|
195
|
+
fi
|
|
196
|
+
fi
|
|
197
|
+
exec npx refrakt plan "$@"
|
|
198
|
+
`;
|
|
199
|
+
/**
|
|
200
|
+
* Read this plan package's own version so we can pin host devDependencies
|
|
201
|
+
* to a range compatible with the CLI that's running init.
|
|
93
202
|
*/
|
|
203
|
+
function getOwnVersion() {
|
|
204
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
205
|
+
// Built: dist/commands/init.js → ../../package.json
|
|
206
|
+
// Source (vitest via tsx): src/commands/init.ts → ../../package.json
|
|
207
|
+
const candidates = [
|
|
208
|
+
join(here, '..', '..', 'package.json'),
|
|
209
|
+
join(here, '..', '..', '..', 'package.json'),
|
|
210
|
+
];
|
|
211
|
+
for (const p of candidates) {
|
|
212
|
+
try {
|
|
213
|
+
const pkg = JSON.parse(readFileSync(p, 'utf-8'));
|
|
214
|
+
if (pkg && pkg.name === '@refrakt-md/plan' && typeof pkg.version === 'string') {
|
|
215
|
+
return pkg.version;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
// try next candidate
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return '*';
|
|
223
|
+
}
|
|
224
|
+
/** Detect which agent instruction files already exist in the project root. */
|
|
94
225
|
function detectAgentFiles(projectRoot) {
|
|
95
226
|
const found = [];
|
|
96
227
|
for (const relPath of Object.values(AGENT_FILES)) {
|
|
@@ -100,8 +231,13 @@ function detectAgentFiles(projectRoot) {
|
|
|
100
231
|
}
|
|
101
232
|
return found;
|
|
102
233
|
}
|
|
234
|
+
function hasPointerMarker(content) {
|
|
235
|
+
if (content.includes(POINTER_MARKER))
|
|
236
|
+
return true;
|
|
237
|
+
return LEGACY_POINTER_MARKERS.some(m => content.includes(m));
|
|
238
|
+
}
|
|
103
239
|
/**
|
|
104
|
-
* Append the plan pointer section to
|
|
240
|
+
* Append the plan pointer section to a tool-specific agent instruction file.
|
|
105
241
|
* Creates the file (and parent directories) if it doesn't exist.
|
|
106
242
|
* Returns true if the file was updated.
|
|
107
243
|
*/
|
|
@@ -109,26 +245,153 @@ function appendPointer(projectRoot, relPath) {
|
|
|
109
245
|
const filePath = join(projectRoot, relPath);
|
|
110
246
|
if (existsSync(filePath)) {
|
|
111
247
|
const content = readFileSync(filePath, 'utf-8');
|
|
112
|
-
if (
|
|
248
|
+
if (hasPointerMarker(content)) {
|
|
113
249
|
return false;
|
|
114
250
|
}
|
|
115
|
-
appendFileSync(filePath,
|
|
251
|
+
appendFileSync(filePath, POINTER_LINE);
|
|
116
252
|
return true;
|
|
117
253
|
}
|
|
118
254
|
const dir = dirname(filePath);
|
|
119
255
|
if (!existsSync(dir)) {
|
|
120
256
|
mkdirSync(dir, { recursive: true });
|
|
121
257
|
}
|
|
122
|
-
writeFileSync(filePath,
|
|
258
|
+
writeFileSync(filePath, POINTER_LINE.trimStart());
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Write AGENTS.md if it doesn't exist; if it exists but lacks our plan
|
|
263
|
+
* workflow section, append it. Returns true if the file was created or
|
|
264
|
+
* modified.
|
|
265
|
+
*/
|
|
266
|
+
function writeAgentsFile(projectRoot) {
|
|
267
|
+
const filePath = join(projectRoot, AGENTS_FILE);
|
|
268
|
+
if (!existsSync(filePath)) {
|
|
269
|
+
writeFileSync(filePath, AGENTS_MD_CONTENT);
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
273
|
+
if (content.includes('## Plan — Workflow Guide') || content.includes('refrakt plan next')) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
// Append plan section to existing AGENTS.md (preserve user content above).
|
|
277
|
+
const planSectionStart = AGENTS_MD_CONTENT.indexOf('## Plan — Workflow Guide');
|
|
278
|
+
const planSection = planSectionStart >= 0 ? AGENTS_MD_CONTENT.slice(planSectionStart) : AGENTS_MD_CONTENT;
|
|
279
|
+
const separator = content.endsWith('\n') ? '\n' : '\n\n';
|
|
280
|
+
appendFileSync(filePath, separator + planSection);
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Merge plan-related entries into an existing package.json or create one.
|
|
285
|
+
* Never overwrites existing keys. Returns true if the file was modified.
|
|
286
|
+
*/
|
|
287
|
+
function updateHostPackageJson(pkgJsonPath, versions) {
|
|
288
|
+
let pkg = {};
|
|
289
|
+
try {
|
|
290
|
+
pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
let changed = false;
|
|
296
|
+
if (!pkg.scripts || typeof pkg.scripts !== 'object') {
|
|
297
|
+
pkg.scripts = {};
|
|
298
|
+
}
|
|
299
|
+
if (!pkg.scripts.plan) {
|
|
300
|
+
pkg.scripts.plan = 'refrakt plan';
|
|
301
|
+
changed = true;
|
|
302
|
+
}
|
|
303
|
+
if (!pkg.devDependencies || typeof pkg.devDependencies !== 'object') {
|
|
304
|
+
pkg.devDependencies = {};
|
|
305
|
+
}
|
|
306
|
+
const deps = pkg.devDependencies;
|
|
307
|
+
const alreadyInDeps = (name) => (pkg.dependencies && pkg.dependencies[name]) ||
|
|
308
|
+
(pkg.devDependencies && pkg.devDependencies[name]);
|
|
309
|
+
if (!alreadyInDeps('@refrakt-md/cli')) {
|
|
310
|
+
deps['@refrakt-md/cli'] = `^${versions.cli}`;
|
|
311
|
+
changed = true;
|
|
312
|
+
}
|
|
313
|
+
if (!alreadyInDeps('@refrakt-md/plan')) {
|
|
314
|
+
deps['@refrakt-md/plan'] = `^${versions.plan}`;
|
|
315
|
+
changed = true;
|
|
316
|
+
}
|
|
317
|
+
if (changed) {
|
|
318
|
+
writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
319
|
+
}
|
|
320
|
+
return changed;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Write (or merge into) .claude/settings.json with a SessionStart hook that
|
|
324
|
+
* installs dependencies if `refrakt` isn't resolvable. If the file already
|
|
325
|
+
* contains our hook command, leave it alone.
|
|
326
|
+
*/
|
|
327
|
+
function writeClaudeHook(projectRoot) {
|
|
328
|
+
const settingsDir = join(projectRoot, '.claude');
|
|
329
|
+
const settingsPath = join(settingsDir, 'settings.json');
|
|
330
|
+
let settings = {};
|
|
331
|
+
if (existsSync(settingsPath)) {
|
|
332
|
+
try {
|
|
333
|
+
settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (!settings.hooks)
|
|
340
|
+
settings.hooks = {};
|
|
341
|
+
if (!Array.isArray(settings.hooks.SessionStart))
|
|
342
|
+
settings.hooks.SessionStart = [];
|
|
343
|
+
for (const block of settings.hooks.SessionStart) {
|
|
344
|
+
if (!block.hooks)
|
|
345
|
+
continue;
|
|
346
|
+
if (block.hooks.some(h => h.command === HOOK_COMMAND)) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
settings.hooks.SessionStart.push({
|
|
351
|
+
hooks: [{ type: 'command', command: HOOK_COMMAND }],
|
|
352
|
+
});
|
|
353
|
+
if (!existsSync(settingsDir)) {
|
|
354
|
+
mkdirSync(settingsDir, { recursive: true });
|
|
355
|
+
}
|
|
356
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
123
357
|
return true;
|
|
124
358
|
}
|
|
125
359
|
/**
|
|
126
|
-
*
|
|
360
|
+
* Write a ./plan.sh wrapper script and mark it executable. We use `.sh`
|
|
361
|
+
* because the default content directory is also called `plan/` and a file
|
|
362
|
+
* named `plan` can't coexist with a directory of the same name in a single
|
|
363
|
+
* parent. Users run `./plan.sh next` (or just `npm run plan -- next`).
|
|
364
|
+
*/
|
|
365
|
+
function writeWrapperScript(projectRoot) {
|
|
366
|
+
const scriptPath = join(projectRoot, 'plan.sh');
|
|
367
|
+
if (existsSync(scriptPath)) {
|
|
368
|
+
const existing = readFileSync(scriptPath, 'utf-8');
|
|
369
|
+
if (existing === WRAPPER_SCRIPT)
|
|
370
|
+
return false;
|
|
371
|
+
// A different file already exists at ./plan.sh — don't clobber it.
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
writeFileSync(scriptPath, WRAPPER_SCRIPT);
|
|
375
|
+
try {
|
|
376
|
+
chmodSync(scriptPath, 0o755);
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
// Best-effort on platforms without POSIX perms (Windows).
|
|
380
|
+
}
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Initialize a plan directory structure, wire the host project for agent use,
|
|
385
|
+
* and (optionally) install a Claude SessionStart hook + ./plan wrapper.
|
|
127
386
|
*/
|
|
128
387
|
export function runInit(options) {
|
|
129
|
-
const { dir, projectRoot = '.', agent } = options;
|
|
388
|
+
const { dir, projectRoot = '.', agent, noPackageJson = false, noHooks = false, noWrapper = false, } = options;
|
|
389
|
+
const versions = options.versions ?? (() => {
|
|
390
|
+
const v = getOwnVersion();
|
|
391
|
+
return { cli: v, plan: v };
|
|
392
|
+
})();
|
|
130
393
|
const created = [];
|
|
131
|
-
//
|
|
394
|
+
// --- 1. plan/ scaffolding ------------------------------------------------
|
|
132
395
|
const dirs = ['work', 'specs', 'decisions', 'milestones'];
|
|
133
396
|
for (const sub of dirs) {
|
|
134
397
|
const path = join(dir, sub);
|
|
@@ -137,7 +400,6 @@ export function runInit(options) {
|
|
|
137
400
|
created.push(path + '/');
|
|
138
401
|
}
|
|
139
402
|
}
|
|
140
|
-
// Create example files — use runCreate which generates slug-based filenames
|
|
141
403
|
const examples = [
|
|
142
404
|
{ type: 'spec', id: 'SPEC-001', title: 'Example Spec', subDir: 'specs', slug: 'example-spec.md' },
|
|
143
405
|
{ type: 'work', id: 'WORK-001', title: 'Example Work Item', subDir: 'work', slug: 'example-work-item.md', attrs: { priority: 'medium', complexity: 'simple', tags: '' } },
|
|
@@ -151,7 +413,6 @@ export function runInit(options) {
|
|
|
151
413
|
created.push(filePath);
|
|
152
414
|
}
|
|
153
415
|
}
|
|
154
|
-
// Create status filter pages for each type
|
|
155
416
|
for (const def of STATUS_PAGES) {
|
|
156
417
|
const slug = `${def.status}.md`;
|
|
157
418
|
const filePath = join(dir, def.typeDir, slug);
|
|
@@ -160,7 +421,6 @@ export function runInit(options) {
|
|
|
160
421
|
created.push(filePath);
|
|
161
422
|
}
|
|
162
423
|
}
|
|
163
|
-
// Create type-level index pages with links to status filter pages
|
|
164
424
|
const typeDirs = [...new Set(STATUS_PAGES.map(p => p.typeDir))];
|
|
165
425
|
for (const typeDir of typeDirs) {
|
|
166
426
|
const filePath = join(dir, typeDir, 'index.md');
|
|
@@ -169,7 +429,6 @@ export function runInit(options) {
|
|
|
169
429
|
created.push(filePath);
|
|
170
430
|
}
|
|
171
431
|
}
|
|
172
|
-
// Create index.md
|
|
173
432
|
const indexFile = join(dir, 'index.md');
|
|
174
433
|
if (!existsSync(indexFile)) {
|
|
175
434
|
writeFileSync(indexFile, `# Project Plan
|
|
@@ -193,40 +452,79 @@ refrakt plan create work --id WORK-002 --title "My task"
|
|
|
193
452
|
`);
|
|
194
453
|
created.push(indexFile);
|
|
195
454
|
}
|
|
196
|
-
// Create INSTRUCTIONS.md
|
|
197
455
|
const instructionsFile = join(dir, 'INSTRUCTIONS.md');
|
|
198
456
|
if (!existsSync(instructionsFile)) {
|
|
199
457
|
writeFileSync(instructionsFile, INSTRUCTIONS_CONTENT);
|
|
200
458
|
created.push(instructionsFile);
|
|
201
459
|
}
|
|
202
|
-
//
|
|
460
|
+
// --- 2. AGENTS.md + tool-specific pointers ------------------------------
|
|
203
461
|
const agentFilesUpdated = [];
|
|
204
|
-
if (agent
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
else if (agent) {
|
|
208
|
-
// Specific agent requested
|
|
209
|
-
const relPath = AGENT_FILES[agent];
|
|
210
|
-
if (relPath && appendPointer(projectRoot, relPath)) {
|
|
211
|
-
agentFilesUpdated.push(relPath);
|
|
462
|
+
if (agent !== 'none') {
|
|
463
|
+
if (writeAgentsFile(projectRoot)) {
|
|
464
|
+
agentFilesUpdated.push(AGENTS_FILE);
|
|
212
465
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
}
|
|
466
|
+
const writePointer = (relPath) => {
|
|
467
|
+
if (appendPointer(projectRoot, relPath)) {
|
|
468
|
+
agentFilesUpdated.push(relPath);
|
|
222
469
|
}
|
|
470
|
+
};
|
|
471
|
+
if (agent) {
|
|
472
|
+
const relPath = AGENT_FILES[agent];
|
|
473
|
+
if (relPath)
|
|
474
|
+
writePointer(relPath);
|
|
223
475
|
}
|
|
224
476
|
else {
|
|
225
|
-
|
|
226
|
-
|
|
477
|
+
const existing = detectAgentFiles(projectRoot);
|
|
478
|
+
if (existing.length > 0) {
|
|
479
|
+
for (const relPath of existing)
|
|
480
|
+
writePointer(relPath);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
// Fallback: ensure Claude Code has a pointer since it's our primary audience.
|
|
484
|
+
writePointer(AGENT_FILES.claude);
|
|
227
485
|
}
|
|
228
486
|
}
|
|
229
487
|
}
|
|
230
|
-
|
|
488
|
+
// --- 3. Host package.json wiring ---------------------------------------
|
|
489
|
+
const installRootInfo = findInstallRoot(projectRoot);
|
|
490
|
+
const packageManager = installRootInfo ? detectPackageManager(installRootInfo.rootDir) : null;
|
|
491
|
+
let packageJsonUpdated = false;
|
|
492
|
+
if (!noPackageJson && installRootInfo) {
|
|
493
|
+
packageJsonUpdated = updateHostPackageJson(installRootInfo.packageJsonPath, versions);
|
|
494
|
+
}
|
|
495
|
+
// --- 4. Claude SessionStart hook (gated) -------------------------------
|
|
496
|
+
let hookWritten = false;
|
|
497
|
+
const shouldWriteHook = (() => {
|
|
498
|
+
if (noHooks)
|
|
499
|
+
return false;
|
|
500
|
+
if (agent === 'none')
|
|
501
|
+
return false;
|
|
502
|
+
if (agent === 'claude')
|
|
503
|
+
return true;
|
|
504
|
+
if (agent)
|
|
505
|
+
return false; // explicit non-claude agent
|
|
506
|
+
// auto-detect: write if CLAUDE.md exists or was just created
|
|
507
|
+
return existsSync(join(projectRoot, AGENT_FILES.claude));
|
|
508
|
+
})();
|
|
509
|
+
if (shouldWriteHook) {
|
|
510
|
+
hookWritten = writeClaudeHook(projectRoot);
|
|
511
|
+
}
|
|
512
|
+
// --- 5. ./plan.sh wrapper script ---------------------------------------
|
|
513
|
+
let wrapperWritten = false;
|
|
514
|
+
if (!noWrapper && agent !== 'none') {
|
|
515
|
+
wrapperWritten = writeWrapperScript(projectRoot);
|
|
516
|
+
}
|
|
517
|
+
return {
|
|
518
|
+
dir,
|
|
519
|
+
created,
|
|
520
|
+
agentFilesUpdated,
|
|
521
|
+
packageJsonUpdated,
|
|
522
|
+
hookWritten,
|
|
523
|
+
wrapperWritten,
|
|
524
|
+
installRoot: installRootInfo ? installRootInfo.rootDir : null,
|
|
525
|
+
packageManager,
|
|
526
|
+
};
|
|
231
527
|
}
|
|
528
|
+
// Re-export for consumers that want to introspect the install command logic.
|
|
529
|
+
export { installCommand };
|
|
232
530
|
//# 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;AACxF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErF,M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AK,CAAC;QACnC,IAAI,KAAK,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QACpC,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,CAAC,4BAA4B;QACrD,6DAA6D;QAC7D,OAAO,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,EAAE,CAAC;IACL,IAAI,eAAe,EAAE,CAAC;QACrB,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,24 @@
|
|
|
1
|
+
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
2
|
+
export interface InstallRoot {
|
|
3
|
+
/** Absolute path to the package.json file. */
|
|
4
|
+
packageJsonPath: string;
|
|
5
|
+
/** Directory containing the package.json. */
|
|
6
|
+
rootDir: string;
|
|
7
|
+
/** True if this package declares a workspace (npm/yarn workspaces, pnpm workspace, or lerna). */
|
|
8
|
+
isWorkspaceRoot: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Walk up from `startDir` looking for the nearest package.json. If any
|
|
12
|
+
* ancestor is a workspace root (declares `workspaces`, or has a sibling
|
|
13
|
+
* `pnpm-workspace.yaml` / `lerna.json`), prefer that. Returns null if no
|
|
14
|
+
* package.json is reachable within MAX_ASCENT levels.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findInstallRoot(startDir: string): InstallRoot | null;
|
|
17
|
+
/**
|
|
18
|
+
* Detect the package manager for a project by looking at lockfiles in
|
|
19
|
+
* `rootDir`. Returns 'npm' as the default when no lockfile is present.
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectPackageManager(rootDir: string): PackageManager;
|
|
22
|
+
/** Shell command that installs dependencies for the given package manager. */
|
|
23
|
+
export declare function installCommand(pm: PackageManager): string;
|
|
24
|
+
//# sourceMappingURL=project-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-setup.d.ts","sourceRoot":"","sources":["../../src/commands/project-setup.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC3B,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,iGAAiG;IACjG,eAAe,EAAE,OAAO,CAAC;CACzB;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CA2BpE;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAWpE;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAQzD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { dirname, join, resolve } from 'path';
|
|
3
|
+
const MAX_ASCENT = 6;
|
|
4
|
+
/**
|
|
5
|
+
* Walk up from `startDir` looking for the nearest package.json. If any
|
|
6
|
+
* ancestor is a workspace root (declares `workspaces`, or has a sibling
|
|
7
|
+
* `pnpm-workspace.yaml` / `lerna.json`), prefer that. Returns null if no
|
|
8
|
+
* package.json is reachable within MAX_ASCENT levels.
|
|
9
|
+
*/
|
|
10
|
+
export function findInstallRoot(startDir) {
|
|
11
|
+
const start = resolve(startDir);
|
|
12
|
+
let nearest = null;
|
|
13
|
+
let current = start;
|
|
14
|
+
for (let i = 0; i <= MAX_ASCENT; i++) {
|
|
15
|
+
const pkgPath = join(current, 'package.json');
|
|
16
|
+
if (existsSync(pkgPath)) {
|
|
17
|
+
const isWorkspace = detectWorkspaceRoot(current, pkgPath);
|
|
18
|
+
const candidate = {
|
|
19
|
+
packageJsonPath: pkgPath,
|
|
20
|
+
rootDir: current,
|
|
21
|
+
isWorkspaceRoot: isWorkspace,
|
|
22
|
+
};
|
|
23
|
+
if (isWorkspace) {
|
|
24
|
+
return candidate;
|
|
25
|
+
}
|
|
26
|
+
if (!nearest) {
|
|
27
|
+
nearest = candidate;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const parent = dirname(current);
|
|
31
|
+
if (parent === current)
|
|
32
|
+
break;
|
|
33
|
+
current = parent;
|
|
34
|
+
}
|
|
35
|
+
return nearest;
|
|
36
|
+
}
|
|
37
|
+
function detectWorkspaceRoot(dir, pkgPath) {
|
|
38
|
+
if (existsSync(join(dir, 'pnpm-workspace.yaml')))
|
|
39
|
+
return true;
|
|
40
|
+
if (existsSync(join(dir, 'lerna.json')))
|
|
41
|
+
return true;
|
|
42
|
+
try {
|
|
43
|
+
const raw = readFileSync(pkgPath, 'utf-8');
|
|
44
|
+
const pkg = JSON.parse(raw);
|
|
45
|
+
if (pkg && pkg.workspaces)
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Malformed package.json — treat as non-workspace.
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detect the package manager for a project by looking at lockfiles in
|
|
55
|
+
* `rootDir`. Returns 'npm' as the default when no lockfile is present.
|
|
56
|
+
*/
|
|
57
|
+
export function detectPackageManager(rootDir) {
|
|
58
|
+
if (existsSync(join(rootDir, 'bun.lockb')) || existsSync(join(rootDir, 'bun.lock'))) {
|
|
59
|
+
return 'bun';
|
|
60
|
+
}
|
|
61
|
+
if (existsSync(join(rootDir, 'pnpm-lock.yaml'))) {
|
|
62
|
+
return 'pnpm';
|
|
63
|
+
}
|
|
64
|
+
if (existsSync(join(rootDir, 'yarn.lock'))) {
|
|
65
|
+
return 'yarn';
|
|
66
|
+
}
|
|
67
|
+
return 'npm';
|
|
68
|
+
}
|
|
69
|
+
/** Shell command that installs dependencies for the given package manager. */
|
|
70
|
+
export function installCommand(pm) {
|
|
71
|
+
switch (pm) {
|
|
72
|
+
case 'pnpm': return 'pnpm install';
|
|
73
|
+
case 'yarn': return 'yarn install';
|
|
74
|
+
case 'bun': return 'bun install';
|
|
75
|
+
case 'npm':
|
|
76
|
+
default: return 'npm install';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=project-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-setup.js","sourceRoot":"","sources":["../../src/commands/project-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAa9C,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,IAAI,OAAO,GAAuB,IAAI,CAAC;IACvC,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,O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AAC,OAAO,EAAE,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QACrF,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QACjD,OAAO,MAAM,CAAC;IACf,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;QAC5C,OAAO,MAAM,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,cAAc,CAAC,EAAkB;IAChD,QAAQ,EAAE,EAAE,CAAC;QACZ,KAAK,MAAM,CAAC,CAAC,OAAO,cAAc,CAAC;QACnC,KAAK,MAAM,CAAC,CAAC,OAAO,cAAc,CAAC;QACnC,KAAK,KAAK,CAAC,CAAC,OAAO,aAAa,CAAC;QACjC,KAAK,KAAK,CAAC;QACX,OAAO,CAAC,CAAC,OAAO,aAAa,CAAC;IAC/B,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgBrD,eAAO,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAgBrD,eAAO,MAAM,IAAI,EAAE,WA4HlB,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACjE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|