@nolto/cli 0.13.2 → 0.14.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.
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: roadmap-progress
|
|
3
|
-
description: Maintain a
|
|
3
|
+
description: Maintain a project's server roadmap through the Nolto CLI and its external cache as work starts, completes, becomes blocked, or is replanned. Use when Codex or Claude plans project phases and tasks, begins or finishes an implementation task, reports project progress, records a blocker, or needs to keep the Roadmap Viewer current. Do not mark work done without verification. Attach plan documents to tasks with the plan command.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Roadmap Progress
|
|
7
7
|
|
|
8
|
-
Keep
|
|
8
|
+
Keep the Nolto server roadmap synchronized with verified repository work. The server is the source of truth; the CLI keeps an external JSON cache for reading and structural edits.
|
|
9
9
|
|
|
10
10
|
コミット件名に課題キー(例: NOLTO-50)を含めると、`nolto sync` がコミット / PR を課題に紐づけます(Git 連携スコープが必要)。
|
|
11
11
|
|
|
12
12
|
## Resolve the roadmap
|
|
13
13
|
|
|
14
|
-
1. Use the roadmap named by the user when provided.
|
|
15
|
-
2.
|
|
16
|
-
3. If
|
|
14
|
+
1. Use the roadmap slug named by the user when provided. Run `nolto roadmap path [slug]` to get the absolute cache JSON path. With multiple cached roadmaps, select a slug; task commands use `--slug <slug>`.
|
|
15
|
+
2. If `nolto.json` is missing, guide the user to `nolto init`. Do not invent project scope.
|
|
16
|
+
3. If legacy repo-local roadmaps remain, guide the user to `nolto roadmap migrate`. It preserves the source files and prints cleanup instructions.
|
|
17
17
|
4. Read [references/schema.md](references/schema.md) before creating phases or tasks, changing IDs, or repairing validation errors.
|
|
18
18
|
|
|
19
19
|
## Choose the workflow
|
|
@@ -24,35 +24,33 @@ Read without modifying. Summarize overall completed/total tasks, current task, b
|
|
|
24
24
|
|
|
25
25
|
### Start work
|
|
26
26
|
|
|
27
|
-
Before implementation,
|
|
27
|
+
Before implementation, run `roadmap.mjs start <task-id> [--note text] [--summary text]`. The CLI sends a task PATCH. The server manages task timestamps, phase status, and the calling user's current task.
|
|
28
28
|
|
|
29
29
|
### Complete work
|
|
30
30
|
|
|
31
|
-
Run relevant verification first. Only after verification succeeds,
|
|
31
|
+
Run relevant verification first. Only after verification succeeds, run `roadmap.mjs done <task-id> [--note text] [--summary text]`. If verification fails, keep the task in progress or use `block` with a concrete note.
|
|
32
32
|
|
|
33
33
|
### Record a blocker
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Run `roadmap.mjs block <task-id> --note text [--summary text]`. State the dependency or decision preventing progress and what will unblock it.
|
|
36
36
|
|
|
37
37
|
### Replan
|
|
38
38
|
|
|
39
|
-
Edit
|
|
39
|
+
Edit the JSON returned by `nolto roadmap path [slug]` for structural changes: add, remove, rename, or reorder phases and tasks, or change `dependsOn` and `issues`. Preserve task IDs. Run `nolto roadmap validate [slug]`, then `nolto roadmap sync [slug]`.
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
On a 409 conflict, save unsynced edits, use `nolto roadmap pull [slug]` to refresh, and review the affected tasks before reapplying changes. Pull protects dirty caches; use `--force` only after saving the edits you need.
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
The command warns if the file does not exist yet; create the plan file first
|
|
47
|
-
when possible.
|
|
43
|
+
### Attach a plan or update the summary
|
|
44
|
+
|
|
45
|
+
Run `roadmap.mjs plan <task-id> --path <repo-relative-md>` to PATCH the link and sync the plan document. Run `roadmap.mjs summary [slug] --text text` to update the summary and sync it with PUT. Do not directly edit state, notes, plan links, or summary for these workflows.
|
|
48
46
|
|
|
49
47
|
### Work with issues
|
|
50
48
|
|
|
51
49
|
When issue work is authorized, first search for duplicates with `nolto issue list --q "<keyword>" --closed include`.
|
|
52
|
-
Create with `nolto issue create --subject "…"
|
|
50
|
+
Create with `nolto issue create --subject "…"`. Add the returned key to the task’s `issues` in the cache, then validate and sync using the Replan workflow. The legacy `issue create --phase` option still edits repository files; do not use it for the external cache.
|
|
53
51
|
After implementing and verifying a fix, record the transition and explanation with `nolto issue update <key> --status <name> -m "…"`; use `nolto issue comment <key> -m "…"` for a separate progress note.
|
|
54
52
|
Close verified work with `nolto issue close <key> -m "…"`.
|
|
55
|
-
If
|
|
53
|
+
If linking fails after issue creation, repair the existing key in the cache; do not create another issue.
|
|
56
54
|
On HTTP 429, wait the `Retry-After` seconds and retry once only.
|
|
57
55
|
A 403 `token_scope` / `token_project` requires a suitably scoped token from the user; inspect `nolto whoami` and request access rather than retrying the same operation.
|
|
58
56
|
See [references/issue-cli.md](references/issue-cli.md) for commands, options, examples and exit codes.
|
|
@@ -67,17 +65,19 @@ Resolve the script relative to this `SKILL.md`. Common repository installs are:
|
|
|
67
65
|
Supported commands:
|
|
68
66
|
|
|
69
67
|
```text
|
|
70
|
-
roadmap.mjs [
|
|
71
|
-
roadmap.mjs [--
|
|
72
|
-
roadmap.mjs
|
|
73
|
-
roadmap.mjs
|
|
74
|
-
roadmap.mjs
|
|
75
|
-
roadmap.mjs
|
|
76
|
-
roadmap.mjs [--
|
|
77
|
-
roadmap.mjs [
|
|
68
|
+
roadmap.mjs path [slug]
|
|
69
|
+
roadmap.mjs status [slug] [--fresh]
|
|
70
|
+
roadmap.mjs validate [slug]
|
|
71
|
+
roadmap.mjs start <task-id> [--slug slug] [--note text] [--summary text]
|
|
72
|
+
roadmap.mjs done <task-id> [--slug slug] [--note text] [--summary text]
|
|
73
|
+
roadmap.mjs block <task-id> [--slug slug] --note text [--summary text]
|
|
74
|
+
roadmap.mjs todo <task-id> [--slug slug] [--note text]
|
|
75
|
+
roadmap.mjs summary [slug] --text text
|
|
76
|
+
roadmap.mjs plan <task-id> [--slug slug] --path <repo-relative-md>
|
|
77
|
+
roadmap.mjs events [slug] [--since revision] [--limit number]
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
The wrapper invokes `nolto roadmap`; install `@nolto/cli` if `nolto` is unavailable. `--file` is no longer supported. Task changes use PATCH; structural edits and summaries use PUT. Dirty structural changes must be synced before a task PATCH. `--summary` on start/done/block runs a separate summary command only after the task command succeeds.
|
|
81
81
|
|
|
82
82
|
## Guardrails
|
|
83
83
|
|
|
@@ -85,15 +85,12 @@ Use direct JSON edits to add, remove, rename, or reorder phases and tasks, then
|
|
|
85
85
|
|
|
86
86
|
- `issues` items must be issue keys like `NOLTO-12`, unique; put them on tasks only.
|
|
87
87
|
|
|
88
|
-
- `schemaVersion` is
|
|
89
|
-
|
|
90
|
-
`schemaVersion` by hand.
|
|
91
|
-
- The roadmap script writes local files. `nolto issue` writes to Nolto when issue work is authorized; `nolto sync` / `nolto watch` publishes local roadmap changes.
|
|
88
|
+
- `schemaVersion` is 3. Legacy v1/v2 files still validate; `nolto roadmap migrate` upgrades repository files into the cache. Never edit `schemaVersion` by hand.
|
|
89
|
+
- The roadmap commands write to Nolto. `nolto issue` writes to Nolto when issue work is authorized; `nolto roadmap sync` / `nolto watch` publishes structural cache edits.
|
|
92
90
|
- Use only `todo`, `in-progress`, `done`, and `blocked`. Convert legacy `in_progress` when touching that entry.
|
|
93
91
|
- Keep all phase and task IDs unique across the file.
|
|
94
92
|
- Preserve task IDs across title changes so `dependsOn` remains stable.
|
|
95
|
-
-
|
|
96
|
-
- Require `completedAt` for done tasks and `startedAt` for in-progress tasks.
|
|
93
|
+
- `currentTaskId` is user-specific and server-managed. Do not write it or `updatedAt` into the cache JSON. The server sets `startedAt` and `completedAt` on task state changes; do not edit them manually.
|
|
97
94
|
- Timestamps must be RFC 3339 with a timezone offset (`2026-09-02T10:00:00+09:00` or `2026-09-02T01:00:00Z`; never `2026-09-02T10:00:00`); `dependsOn` items must be plain task ID strings and unique.
|
|
98
95
|
- Keep notes factual and current; replace stale implementation notes instead of accumulating a log.
|
|
99
96
|
- Never rewrite repository history or source code solely to make the roadmap appear complete.
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
# Roadmap schema
|
|
2
2
|
|
|
3
|
-
Use this reference when creating or structurally editing
|
|
3
|
+
Use this reference when creating or structurally editing the cache JSON returned by `nolto roadmap path [slug]`.
|
|
4
4
|
|
|
5
5
|
## Shape
|
|
6
6
|
|
|
7
7
|
```json
|
|
8
8
|
{
|
|
9
|
-
"schemaVersion":
|
|
9
|
+
"schemaVersion": 3,
|
|
10
10
|
"project": {
|
|
11
11
|
"id": "my-api",
|
|
12
12
|
"name": "My API",
|
|
13
13
|
"repository": "/absolute/path/to/my-api"
|
|
14
14
|
},
|
|
15
|
-
"updatedAt": "2026-07-20T14:30:00+09:00",
|
|
16
|
-
"currentTaskId": "task-004",
|
|
17
15
|
"summary": "セッション管理を実装中。",
|
|
18
16
|
"phases": [
|
|
19
17
|
{
|
|
@@ -51,12 +49,12 @@ Use this reference when creating or structurally editing `.nolto/roadmaps/<slug>
|
|
|
51
49
|
|
|
52
50
|
## Fields
|
|
53
51
|
|
|
54
|
-
- `schemaVersion`: Always `
|
|
52
|
+
- `schemaVersion`: Always `3`.
|
|
55
53
|
- `project.id`: Stable lowercase identifier matching `^[a-z0-9][a-z0-9._-]*$`.
|
|
56
54
|
- `project.name`: Display name.
|
|
57
55
|
- `project.repository`: Absolute repository path when known.
|
|
58
|
-
- `updatedAt`:
|
|
59
|
-
- `currentTaskId`:
|
|
56
|
+
- `updatedAt`: Server-managed; do not write it into the file. Legacy v2 files may retain it. When present, use RFC 3339 with a timezone offset; offset-less and date-only values are rejected.
|
|
57
|
+
- `currentTaskId`: User-specific and server-managed; do not write it into the file. Legacy v2 files may retain it.
|
|
60
58
|
- `summary`: One or two current sentences; do not use as a changelog.
|
|
61
59
|
- `phases`: Ordered delivery phases.
|
|
62
60
|
- `phase.status`: `todo`, `in-progress`, `done`, or `blocked`.
|
|
@@ -64,8 +62,8 @@ Use this reference when creating or structurally editing `.nolto/roadmaps/<slug>
|
|
|
64
62
|
- `tasks`: Ordered work items. Each must be small enough to verify clearly.
|
|
65
63
|
- `task.status`: `todo`, `in-progress`, `done`, or `blocked`.
|
|
66
64
|
- `task.plan`: Optional repository-relative path (`/`-separated) to a Markdown plan document, for example `docs/plans/auth.md`. Absolute paths, backslashes, and `.`/`..` segments are rejected.
|
|
67
|
-
- `startedAt`:
|
|
68
|
-
- `completedAt`:
|
|
65
|
+
- `startedAt`: Set by the server for `in-progress` tasks; do not edit manually. Uses the same RFC 3339 date-time format as `updatedAt`.
|
|
66
|
+
- `completedAt`: Set by the server for `done` tasks; do not edit manually. Uses the same RFC 3339 date-time format as `updatedAt`.
|
|
69
67
|
- `note`: Current implementation detail or blocker. Omit when it adds no value.
|
|
70
68
|
- `dependsOn`: IDs of prerequisite tasks in the same roadmap. Each item must be a string matching `^[a-z0-9][a-z0-9._-]*$`; duplicates are rejected.
|
|
71
69
|
|
|
@@ -1,307 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Keep in sync with packages/roadmap-schema/src/index.ts isValidPlanPath.
|
|
18
|
-
function isValidPlanPath(value) {
|
|
19
|
-
if (typeof value !== "string" || value.length === 0) return false;
|
|
20
|
-
if (value.includes("\\") || value.startsWith("/") || /^[A-Za-z]:/.test(value)) return false;
|
|
21
|
-
return value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function parseArguments(argv) {
|
|
25
|
-
const options = { file: null, note: undefined, summary: undefined, text: undefined, path: undefined, positional: [] };
|
|
26
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
27
|
-
const value = argv[index];
|
|
28
|
-
if (value === "--file") options.file = argv[++index];
|
|
29
|
-
else if (value === "--note") options.note = argv[++index];
|
|
30
|
-
else if (value === "--summary") options.summary = argv[++index];
|
|
31
|
-
else if (value === "--text") options.text = argv[++index];
|
|
32
|
-
else if (value === "--path") options.path = argv[++index];
|
|
33
|
-
else options.positional.push(value);
|
|
34
|
-
}
|
|
35
|
-
return options;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function findRoadmap(explicitPath) {
|
|
39
|
-
if (explicitPath) return path.resolve(explicitPath);
|
|
40
|
-
|
|
41
|
-
const directories = [];
|
|
42
|
-
let directory = process.cwd();
|
|
43
|
-
while (true) {
|
|
44
|
-
directories.push(directory);
|
|
45
|
-
const roadmapsDirectory = path.join(directory, ".nolto", "roadmaps");
|
|
46
|
-
try {
|
|
47
|
-
const candidates = (await readdir(roadmapsDirectory, { withFileTypes: true }))
|
|
48
|
-
.filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
|
|
49
|
-
.map((entry) => path.join(roadmapsDirectory, entry.name))
|
|
50
|
-
.sort();
|
|
51
|
-
if (candidates.length === 1) return candidates[0];
|
|
52
|
-
if (candidates.length > 1) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Multiple roadmaps found; pass --file <path> to choose one:\n ${candidates.join("\n ")}`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
} catch (error) {
|
|
58
|
-
if (error?.code !== "ENOENT") throw error;
|
|
59
|
-
}
|
|
60
|
-
const parent = path.dirname(directory);
|
|
61
|
-
if (parent === directory) break;
|
|
62
|
-
directory = parent;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
for (const candidateRoot of directories) {
|
|
66
|
-
const legacyCandidate = path.join(candidateRoot, ".roadmap", "roadmap.json");
|
|
67
|
-
try {
|
|
68
|
-
await access(legacyCandidate);
|
|
69
|
-
console.warn(
|
|
70
|
-
`WARN deprecated roadmap path ${legacyCandidate}; migrate it to .nolto/roadmaps/<slug>.json`
|
|
71
|
-
);
|
|
72
|
-
return legacyCandidate;
|
|
73
|
-
} catch {
|
|
74
|
-
// Continue walking upward.
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
throw new Error("No .nolto/roadmaps/*.json found. Pass --file <path>.");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function repoRootForRoadmap(filePath) {
|
|
81
|
-
const parent = path.dirname(filePath);
|
|
82
|
-
if (path.basename(parent) === "roadmaps" && path.basename(path.dirname(parent)) === ".nolto") {
|
|
83
|
-
return path.dirname(path.dirname(parent));
|
|
84
|
-
}
|
|
85
|
-
if (path.basename(parent) === ".roadmap") return path.dirname(parent);
|
|
86
|
-
return path.dirname(filePath);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function localIsoNow() {
|
|
90
|
-
const date = new Date();
|
|
91
|
-
const offsetMinutes = -date.getTimezoneOffset();
|
|
92
|
-
const sign = offsetMinutes >= 0 ? "+" : "-";
|
|
93
|
-
const pad = (value) => String(Math.abs(value)).padStart(2, "0");
|
|
94
|
-
const local = new Date(date.getTime() + offsetMinutes * 60_000).toISOString().slice(0, -1);
|
|
95
|
-
return `${local}${sign}${pad(Math.trunc(offsetMinutes / 60))}:${pad(offsetMinutes % 60)}`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function checkKeys(value, allowed, at, errors) {
|
|
99
|
-
for (const key of Object.keys(value ?? {})) {
|
|
100
|
-
if (!allowed.has(key)) errors.push(`${at} contains unsupported property "${key}".`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function validate(roadmap) {
|
|
105
|
-
const errors = [];
|
|
106
|
-
const warnings = [];
|
|
107
|
-
if (!roadmap || typeof roadmap !== "object" || Array.isArray(roadmap)) return { errors: ["Root must be an object."], warnings };
|
|
108
|
-
checkKeys(roadmap, ALLOWED_KEYS.roadmap, "roadmap", errors);
|
|
109
|
-
if (roadmap.schemaVersion !== 1 && roadmap.schemaVersion !== 2) {
|
|
110
|
-
errors.push("schemaVersion must be 1 or 2.");
|
|
111
|
-
} else if (roadmap.schemaVersion === 1) {
|
|
112
|
-
warnings.push("schemaVersion 1 is legacy; the next mutation migrates this file to 2.");
|
|
113
|
-
}
|
|
114
|
-
checkKeys(roadmap.project, ALLOWED_KEYS.project, "project", errors);
|
|
115
|
-
if (!roadmap.project || !ID_PATTERN.test(roadmap.project.id ?? "")) errors.push("project.id is invalid.");
|
|
116
|
-
if (!roadmap.project?.name) errors.push("project.name is required.");
|
|
117
|
-
if (!roadmap.project?.repository) errors.push("project.repository is required.");
|
|
118
|
-
if (Number.isNaN(Date.parse(roadmap.updatedAt))) errors.push("updatedAt must be a valid date-time.");
|
|
119
|
-
if (typeof roadmap.summary !== "string") errors.push("summary must be a string.");
|
|
120
|
-
if (!Array.isArray(roadmap.phases)) errors.push("phases must be an array.");
|
|
121
|
-
|
|
122
|
-
const allIds = new Set();
|
|
123
|
-
const tasks = new Map();
|
|
124
|
-
for (const [phaseIndex, phase] of (Array.isArray(roadmap.phases) ? roadmap.phases : []).entries()) {
|
|
125
|
-
checkKeys(phase, ALLOWED_KEYS.phase, `phases[${phaseIndex}]`, errors);
|
|
126
|
-
if (!ID_PATTERN.test(phase.id ?? "")) errors.push(`phases[${phaseIndex}].id is invalid.`);
|
|
127
|
-
if (allIds.has(phase.id)) errors.push(`Duplicate id "${phase.id}".`);
|
|
128
|
-
allIds.add(phase.id);
|
|
129
|
-
if (!phase.title) errors.push(`phases[${phaseIndex}].title is required.`);
|
|
130
|
-
if (!STATUSES.has(phase.status)) errors.push(`phases[${phaseIndex}].status is invalid.`);
|
|
131
|
-
if (phase.plan !== undefined && (typeof phase.plan !== "string" || phase.plan.length === 0)) {
|
|
132
|
-
errors.push(`phases[${phaseIndex}].plan must be a non-empty string.`);
|
|
133
|
-
}
|
|
134
|
-
if (!Array.isArray(phase.tasks)) errors.push(`phases[${phaseIndex}].tasks must be an array.`);
|
|
135
|
-
for (const [taskIndex, task] of (Array.isArray(phase.tasks) ? phase.tasks : []).entries()) {
|
|
136
|
-
const at = `phases[${phaseIndex}].tasks[${taskIndex}]`;
|
|
137
|
-
checkKeys(task, ALLOWED_KEYS.task, at, errors);
|
|
138
|
-
if (!ID_PATTERN.test(task.id ?? "")) errors.push(`${at}.id is invalid.`);
|
|
139
|
-
if (allIds.has(task.id)) errors.push(`Duplicate id "${task.id}".`);
|
|
140
|
-
allIds.add(task.id);
|
|
141
|
-
tasks.set(task.id, task);
|
|
142
|
-
if (!task.title) errors.push(`${at}.title is required.`);
|
|
143
|
-
if (!STATUSES.has(task.status)) errors.push(`${at}.status is invalid.`);
|
|
144
|
-
if (task.status === "done" && !task.completedAt) warnings.push(`${task.id} is done without completedAt.`);
|
|
145
|
-
if (task.status === "in-progress" && !task.startedAt) warnings.push(`${task.id} is in-progress without startedAt.`);
|
|
146
|
-
if (task.plan !== undefined && (typeof task.plan !== "string" || task.plan.length === 0)) {
|
|
147
|
-
errors.push(`${at}.plan must be a non-empty string.`);
|
|
148
|
-
}
|
|
149
|
-
if (task.issues !== undefined && !Array.isArray(task.issues)) {
|
|
150
|
-
errors.push(`${at}.issues must be an array.`);
|
|
151
|
-
} else if (Array.isArray(task.issues)) {
|
|
152
|
-
const seenIssues = new Set();
|
|
153
|
-
for (const [i, key] of task.issues.entries()) {
|
|
154
|
-
if (typeof key !== "string") { errors.push(`${at}.issues[${i}] must be a string.`); continue; }
|
|
155
|
-
if (!ISSUE_KEY_PATTERN.test(key)) { errors.push(`${at}.issues[${i}] is not an issue key (e.g. NOLTO-12).`); continue; }
|
|
156
|
-
if (seenIssues.has(key)) errors.push(`${at}.issues contains duplicate key "${key}".`);
|
|
157
|
-
seenIssues.add(key);
|
|
158
|
-
}
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
if (args.some(arg => arg === "--file" || arg.startsWith("--file="))) {
|
|
6
|
+
console.error("roadmap-progress: --file is no longer supported; roadmaps live in the nolto cache (nolto roadmap path)");
|
|
7
|
+
process.exit(1);
|
|
8
|
+
}
|
|
9
|
+
if (!args.length) args.push("status");
|
|
10
|
+
let summary;
|
|
11
|
+
if (["start", "done", "block"].includes(args[0])) {
|
|
12
|
+
for (let i = 1; i < args.length; i++) {
|
|
13
|
+
if (args[i] === "--summary") {
|
|
14
|
+
if (args[i + 1] === undefined || args[i + 1].startsWith("--")) {
|
|
15
|
+
console.error("roadmap-progress: --summary requires text");
|
|
16
|
+
process.exit(1);
|
|
159
17
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function findTask(roadmap, taskId) {
|
|
190
|
-
for (const phase of roadmap.phases) {
|
|
191
|
-
const task = phase.tasks.find((item) => item.id === taskId);
|
|
192
|
-
if (task) return { task, phase };
|
|
193
|
-
}
|
|
194
|
-
throw new Error(`Task "${taskId}" not found.`);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function stats(roadmap) {
|
|
198
|
-
const counts = { todo: 0, "in-progress": 0, done: 0, blocked: 0 };
|
|
199
|
-
for (const phase of roadmap.phases) for (const task of phase.tasks) counts[task.status] += 1;
|
|
200
|
-
const total = Object.values(counts).reduce((sum, value) => sum + value, 0);
|
|
201
|
-
return { counts, total, progress: total ? Math.round((counts.done / total) * 100) : 0 };
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
async function atomicWrite(filePath, roadmap) {
|
|
205
|
-
const temporary = `${filePath}.tmp-${process.pid}`;
|
|
206
|
-
await writeFile(temporary, `${JSON.stringify(roadmap, null, 2)}\n`, "utf8");
|
|
207
|
-
await rename(temporary, filePath);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function printStatus(roadmap) {
|
|
211
|
-
const result = stats(roadmap);
|
|
212
|
-
const current = roadmap.currentTaskId ? findTask(roadmap, roadmap.currentTaskId).task : null;
|
|
213
|
-
console.log(`${roadmap.project.name}: ${result.counts.done}/${result.total} done (${result.progress}%)`);
|
|
214
|
-
console.log(`Current: ${current ? `${current.id} — ${current.title}` : "none"}`);
|
|
215
|
-
const blocked = roadmap.phases.flatMap((phase) => phase.tasks).filter((task) => task.status === "blocked");
|
|
216
|
-
console.log(`Blocked: ${blocked.length ? blocked.map((task) => `${task.id} — ${task.title}`).join(", ") : "none"}`);
|
|
217
|
-
if (roadmap.summary) console.log(`Summary: ${roadmap.summary}`);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const options = parseArguments(process.argv.slice(2));
|
|
221
|
-
const [command = "status", taskId] = options.positional;
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
const filePath = await findRoadmap(options.file);
|
|
225
|
-
const roadmap = JSON.parse(await readFile(filePath, "utf8"));
|
|
226
|
-
|
|
227
|
-
if (command === "status") {
|
|
228
|
-
printStatus(roadmap);
|
|
229
|
-
} else if (command === "validate") {
|
|
230
|
-
const result = validate(roadmap);
|
|
231
|
-
for (const warning of result.warnings) console.warn(`WARN ${warning}`);
|
|
232
|
-
if (result.errors.length) {
|
|
233
|
-
for (const error of result.errors) console.error(`ERROR ${error}`);
|
|
234
|
-
process.exitCode = 1;
|
|
235
|
-
} else {
|
|
236
|
-
console.log(`OK ${filePath}`);
|
|
237
|
-
}
|
|
238
|
-
} else if (command === "summary") {
|
|
239
|
-
if (options.text === undefined) throw new Error("summary requires --text.");
|
|
240
|
-
roadmap.summary = options.text;
|
|
241
|
-
roadmap.updatedAt = localIsoNow();
|
|
242
|
-
roadmap.schemaVersion = 2;
|
|
243
|
-
await atomicWrite(filePath, roadmap);
|
|
244
|
-
console.log(`Updated summary in ${filePath}`);
|
|
245
|
-
} else if (["start", "done", "block", "todo"].includes(command)) {
|
|
246
|
-
if (!taskId) throw new Error(`${command} requires a task id.`);
|
|
247
|
-
if (command === "block" && !options.note) throw new Error("block requires a non-empty --note.");
|
|
248
|
-
const { task, phase } = findTask(roadmap, taskId);
|
|
249
|
-
const now = localIsoNow();
|
|
250
|
-
if (command === "start") {
|
|
251
|
-
task.status = "in-progress";
|
|
252
|
-
task.startedAt ??= now;
|
|
253
|
-
delete task.completedAt;
|
|
254
|
-
roadmap.currentTaskId = task.id;
|
|
255
|
-
} else if (command === "done") {
|
|
256
|
-
task.status = "done";
|
|
257
|
-
task.completedAt = now;
|
|
258
|
-
if (roadmap.currentTaskId === task.id) roadmap.currentTaskId = null;
|
|
259
|
-
} else if (command === "block") {
|
|
260
|
-
task.status = "blocked";
|
|
261
|
-
delete task.completedAt;
|
|
262
|
-
if (roadmap.currentTaskId === task.id) roadmap.currentTaskId = null;
|
|
263
|
-
} else {
|
|
264
|
-
task.status = "todo";
|
|
265
|
-
delete task.startedAt;
|
|
266
|
-
delete task.completedAt;
|
|
267
|
-
if (roadmap.currentTaskId === task.id) roadmap.currentTaskId = null;
|
|
268
|
-
}
|
|
269
|
-
if (options.note !== undefined) task.note = options.note;
|
|
270
|
-
if (options.summary !== undefined) roadmap.summary = options.summary;
|
|
271
|
-
phase.status = derivePhaseStatus(phase);
|
|
272
|
-
roadmap.updatedAt = now;
|
|
273
|
-
roadmap.schemaVersion = 2;
|
|
274
|
-
const result = validate(roadmap);
|
|
275
|
-
if (result.errors.length) throw new Error(`Mutation failed validation: ${result.errors.join(" ")}`);
|
|
276
|
-
await atomicWrite(filePath, roadmap);
|
|
277
|
-
console.log(`${task.id} -> ${task.status}`);
|
|
278
|
-
for (const warning of result.warnings) console.warn(`WARN ${warning}`);
|
|
279
|
-
} else if (command === "plan") {
|
|
280
|
-
if (!taskId) throw new Error("plan requires a task id.");
|
|
281
|
-
if (!options.path) throw new Error("plan requires --path <repo-relative-md-path>.");
|
|
282
|
-
if (!isValidPlanPath(options.path)) throw new Error(PLAN_PATH_ERROR);
|
|
283
|
-
const repoRoot = path.resolve(repoRootForRoadmap(filePath));
|
|
284
|
-
const resolvedPlanPath = path.resolve(repoRoot, options.path);
|
|
285
|
-
if (resolvedPlanPath !== repoRoot && !resolvedPlanPath.startsWith(repoRoot + path.sep)) {
|
|
286
|
-
throw new Error(PLAN_PATH_ERROR);
|
|
287
|
-
}
|
|
288
|
-
const { task } = findTask(roadmap, taskId);
|
|
289
|
-
task.plan = options.path;
|
|
290
|
-
roadmap.schemaVersion = 2;
|
|
291
|
-
roadmap.updatedAt = localIsoNow();
|
|
292
|
-
try {
|
|
293
|
-
await access(resolvedPlanPath);
|
|
294
|
-
} catch {
|
|
295
|
-
console.warn(`WARN plan file not found at ${resolvedPlanPath}`);
|
|
296
|
-
}
|
|
297
|
-
const result = validate(roadmap);
|
|
298
|
-
if (result.errors.length) throw new Error(`Mutation failed validation: ${result.errors.join(" ")}`);
|
|
299
|
-
await atomicWrite(filePath, roadmap);
|
|
300
|
-
console.log(`${task.id} plan -> ${options.path}`);
|
|
301
|
-
} else {
|
|
302
|
-
throw new Error(`Unknown command "${command}".`);
|
|
303
|
-
}
|
|
304
|
-
} catch (error) {
|
|
305
|
-
console.error(`roadmap-progress: ${error.message}`);
|
|
306
|
-
process.exitCode = 1;
|
|
307
|
-
}
|
|
18
|
+
summary = args[i + 1];
|
|
19
|
+
args.splice(i--, 2);
|
|
20
|
+
} else if (args[i].startsWith("--summary=")) {
|
|
21
|
+
summary = args[i].slice("--summary=".length);
|
|
22
|
+
args.splice(i--, 1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function run(mapped) {
|
|
27
|
+
const child = spawnSync(process.env.NOLTO_BIN || "nolto", ["roadmap", ...mapped], { stdio: "inherit" });
|
|
28
|
+
if (child.error) {
|
|
29
|
+
console.error(child.error.code === "ENOENT"
|
|
30
|
+
? "roadmap-progress: nolto CLI not found; install with npm i -g @nolto/cli"
|
|
31
|
+
: `roadmap-progress: ${child.error.message}`);
|
|
32
|
+
}
|
|
33
|
+
return child.status ?? 1;
|
|
34
|
+
}
|
|
35
|
+
let code = run(args);
|
|
36
|
+
if (code === 0 && summary !== undefined) {
|
|
37
|
+
const mapped = ["summary"];
|
|
38
|
+
const slugIndex = args.indexOf("--slug");
|
|
39
|
+
const slugOption = args.find(arg => arg.startsWith("--slug="));
|
|
40
|
+
if (slugIndex !== -1) mapped.push(args[slugIndex + 1]);
|
|
41
|
+
else if (slugOption) mapped.push(slugOption.slice("--slug=".length));
|
|
42
|
+
mapped.push("--text", summary);
|
|
43
|
+
if (args.includes("--json")) mapped.push("--json");
|
|
44
|
+
code = run(mapped);
|
|
45
|
+
}
|
|
46
|
+
process.exitCode = code;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nolto/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "CLI for syncing repository roadmaps with Nolto.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/uruca-kk/nolto.git",
|
|
22
|
+
"url": "git+https://github.com/uruca-kk/nolto-frontend.git",
|
|
23
23
|
"directory": "packages/cli"
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://nolto.app",
|