pi-spine 1.0.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.
Files changed (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +563 -0
  3. package/bin/get-version.mjs +35 -0
  4. package/bin/spine-batch.mjs +425 -0
  5. package/bin/spine-cli/batch.mjs +47 -0
  6. package/bin/spine-cli/gate.mjs +10 -0
  7. package/bin/spine-cli/integrate.mjs +10 -0
  8. package/bin/spine-cli/plan.mjs +12 -0
  9. package/bin/spine-cli/shared.mjs +73 -0
  10. package/bin/spine-cli/status.mjs +18 -0
  11. package/bin/spine-cli/verify.mjs +199 -0
  12. package/bin/spine-config.mjs +212 -0
  13. package/bin/spine-dashboard.mjs +178 -0
  14. package/bin/spine-deps.mjs +69 -0
  15. package/bin/spine-doctor.mjs +468 -0
  16. package/bin/spine-gate.mjs +137 -0
  17. package/bin/spine-init.mjs +398 -0
  18. package/bin/spine-integrate.mjs +77 -0
  19. package/bin/spine-journal.mjs +198 -0
  20. package/bin/spine-migrate-from-taskplane.mjs +136 -0
  21. package/bin/spine-plan.mjs +83 -0
  22. package/bin/spine-preflight.mjs +700 -0
  23. package/bin/spine-report-progress.d.mts +28 -0
  24. package/bin/spine-report-progress.mjs +126 -0
  25. package/bin/spine-review-step.d.mts +24 -0
  26. package/bin/spine-review-step.mjs +124 -0
  27. package/bin/spine-rules.mjs +35 -0
  28. package/bin/spine-settings.mjs +186 -0
  29. package/bin/spine-state.mjs +110 -0
  30. package/bin/spine-status.mjs +79 -0
  31. package/bin/spine-tasks.mjs +293 -0
  32. package/bin/spine-worker-runner.mjs +314 -0
  33. package/bin/spine.mjs +404 -0
  34. package/extensions/spine/settings-slash.ts +20 -0
  35. package/extensions/spine/slash-commands.ts +806 -0
  36. package/extensions/spine/worker-tools.ts +279 -0
  37. package/extensions/spine-orchestrator.ts +12 -0
  38. package/package.json +72 -0
  39. package/skills/.gitkeep +0 -0
  40. package/skills/create-spine-tasks/SKILL.md +375 -0
  41. package/skills/create-spine-tasks/references/context-template.md +25 -0
  42. package/skills/create-spine-tasks/references/contract-template.md +98 -0
  43. package/skills/create-spine-tasks/references/explore-template.md +63 -0
  44. package/skills/create-spine-tasks/references/prompt-template.md +276 -0
  45. package/src/batch/abort.mjs +272 -0
  46. package/src/batch/agent-session-worker.mjs +297 -0
  47. package/src/batch/batch-state-io.mjs +53 -0
  48. package/src/batch/contract-verify.mjs +310 -0
  49. package/src/batch/detached-start.mjs +778 -0
  50. package/src/batch/diagnosis.mjs +378 -0
  51. package/src/batch/engine-lanes/merge.mjs +632 -0
  52. package/src/batch/engine-lanes/queue.mjs +208 -0
  53. package/src/batch/engine-lanes/review.mjs +970 -0
  54. package/src/batch/engine-lanes.mjs +388 -0
  55. package/src/batch/engine-scope.mjs +251 -0
  56. package/src/batch/engine.mjs +445 -0
  57. package/src/batch/evidence-command.mjs +157 -0
  58. package/src/batch/evidence.mjs +203 -0
  59. package/src/batch/gate.mjs +359 -0
  60. package/src/batch/git-commit-env.mjs +46 -0
  61. package/src/batch/git-exec.mjs +26 -0
  62. package/src/batch/heartbeat.mjs +430 -0
  63. package/src/batch/integrate.mjs +414 -0
  64. package/src/batch/journal-rebuild.mjs +388 -0
  65. package/src/batch/journal.mjs +373 -0
  66. package/src/batch/lane-commit.mjs +153 -0
  67. package/src/batch/lifecycle.mjs +364 -0
  68. package/src/batch/metrics.mjs +265 -0
  69. package/src/batch/orphan-detect.mjs +210 -0
  70. package/src/batch/post-merge-limbo.mjs +80 -0
  71. package/src/batch/postmortem.mjs +296 -0
  72. package/src/batch/readers/spine-state.mjs +95 -0
  73. package/src/batch/readers/taskplane-state.mjs +136 -0
  74. package/src/batch/reconcile.mjs +729 -0
  75. package/src/batch/resume-common.mjs +104 -0
  76. package/src/batch/resume-engine.mjs +66 -0
  77. package/src/batch/resume-multi-lanes.mjs +479 -0
  78. package/src/batch/resume-multi-validate.mjs +187 -0
  79. package/src/batch/resume-multi.mjs +254 -0
  80. package/src/batch/resume.mjs +475 -0
  81. package/src/batch/retry.mjs +257 -0
  82. package/src/batch/review-scope.mjs +136 -0
  83. package/src/batch/review.mjs +1045 -0
  84. package/src/batch/salvage.mjs +332 -0
  85. package/src/batch/state.mjs +680 -0
  86. package/src/batch/task-stall-budget.mjs +88 -0
  87. package/src/batch/worker-host.mjs +683 -0
  88. package/src/batch/worker-output.mjs +253 -0
  89. package/src/batch/worker-prompt.mjs +84 -0
  90. package/src/batch/worktree.mjs +290 -0
  91. package/src/cli/deps.mjs +141 -0
  92. package/src/cli/handoff.mjs +364 -0
  93. package/src/cli/rules.mjs +429 -0
  94. package/src/cli/settings-set.mjs +171 -0
  95. package/src/cli/settings-show.mjs +140 -0
  96. package/src/cli/settings-slash.mjs +107 -0
  97. package/src/config/contract.mjs +56 -0
  98. package/src/config/cursor-rules/discover.mjs +416 -0
  99. package/src/config/cursor-rules/index.mjs +39 -0
  100. package/src/config/cursor-rules/match-globs.mjs +132 -0
  101. package/src/config/cursor-rules/parse-frontmatter.mjs +222 -0
  102. package/src/config/cursor-rules/priority.mjs +26 -0
  103. package/src/config/cursor-rules/profile.mjs +403 -0
  104. package/src/config/cursor-rules/select.mjs +259 -0
  105. package/src/config/defaults.mjs +36 -0
  106. package/src/config/env-overrides.mjs +207 -0
  107. package/src/config/merge-defaults.mjs +47 -0
  108. package/src/config/pi-spine-root.mjs +93 -0
  109. package/src/config/reviewer-context.mjs +243 -0
  110. package/src/config/settings-fields.mjs +265 -0
  111. package/src/config/worker-backend.mjs +116 -0
  112. package/src/config/worker-context.mjs +402 -0
  113. package/src/config/worker-launch-script.mjs +130 -0
  114. package/src/config/worktree-setup-hook.mjs +122 -0
  115. package/src/dashboard/public/dashboard.css +77 -0
  116. package/src/dashboard/public/dashboard.js +349 -0
  117. package/src/dashboard/public/index.html +80 -0
  118. package/src/dashboard/server.mjs +155 -0
  119. package/src/dashboard/snapshot.mjs +414 -0
  120. package/src/dashboard/sse.mjs +15 -0
  121. package/src/dashboard/view.mjs +292 -0
  122. package/src/doctor/agent-model-inherit.mjs +101 -0
  123. package/src/doctor/batch-size-guidance.mjs +72 -0
  124. package/src/doctor/coexistence.mjs +312 -0
  125. package/src/doctor/rules-manifest.mjs +133 -0
  126. package/src/doctor/stale-path.mjs +156 -0
  127. package/src/doctor/stall-config.mjs +108 -0
  128. package/src/doctor/suggest-max-parallel.mjs +53 -0
  129. package/src/doctor/task-packet-size.mjs +110 -0
  130. package/src/doctor/worktree-health.mjs +71 -0
  131. package/src/migrate/taskplane-config.mjs +116 -0
  132. package/src/planner/cycles.mjs +63 -0
  133. package/src/planner/format-plan.mjs +132 -0
  134. package/src/planner/graph.mjs +99 -0
  135. package/src/planner/index.mjs +125 -0
  136. package/src/planner/lanes.mjs +111 -0
  137. package/src/planner/pending.mjs +39 -0
  138. package/src/planner/scope.mjs +142 -0
  139. package/src/process/liveness.mjs +21 -0
  140. package/src/tasks/packet/discover.mjs +40 -0
  141. package/src/tasks/packet/index.mjs +81 -0
  142. package/src/tasks/packet/merge-deps.mjs +79 -0
  143. package/src/tasks/packet/parse-prompt.mjs +445 -0
  144. package/src/tasks/packet/parse-status.mjs +118 -0
  145. package/src/tasks/packet/validate-contract.mjs +115 -0
  146. package/src/tasks/packet/validate-prompt.mjs +99 -0
  147. package/src/worker-tools/report-progress.d.mts +18 -0
  148. package/src/worker-tools/report-progress.mjs +59 -0
  149. package/src/worker-tools/request-gate.d.mts +17 -0
  150. package/src/worker-tools/request-gate.mjs +54 -0
  151. package/templates/agents/reviewer.md +123 -0
  152. package/templates/agents/supervisor.md +59 -0
  153. package/templates/agents/worker.md +122 -0
  154. package/templates/rules-profile.json +27 -0
  155. package/templates/spine-config.json +64 -0
  156. package/templates/tasks/CONTEXT.md +30 -0
@@ -0,0 +1,140 @@
1
+ /**
2
+ * spine settings show — read-only display of editable spine-config fields (FR-CFG-03).
3
+ */
4
+
5
+ import {
6
+ formatConfigSourceDetail,
7
+ getValueAtPath as getConfigValueAtPath,
8
+ listEnvAwareDisplayFields,
9
+ } from "../config/env-overrides.mjs";
10
+ import { listEditableFields, parseSettingPath } from "../config/settings-fields.mjs";
11
+
12
+ /**
13
+ * @param {unknown} config
14
+ * @param {string} dottedPath
15
+ * @returns {unknown}
16
+ */
17
+ export function getValueAtPath(config, dottedPath) {
18
+ return getConfigValueAtPath(config, dottedPath);
19
+ }
20
+
21
+ /**
22
+ * @param {unknown} value
23
+ * @param {string} type
24
+ * @returns {string}
25
+ */
26
+ function formatSettingValue(value, type) {
27
+ if (value === undefined || value === null) {
28
+ return "(not set)";
29
+ }
30
+ if (type === "boolean") {
31
+ return value ? "true" : "false";
32
+ }
33
+ if (type === "string" && value === "") {
34
+ return "(empty)";
35
+ }
36
+ return String(value);
37
+ }
38
+
39
+ /**
40
+ * @param {object} config
41
+ * @returns {{ path: string, label: string, value: unknown, type: string }[]}
42
+ */
43
+ export function buildSettingsShowFields(config) {
44
+ return listEditableFields().map((field) => ({
45
+ path: field.path,
46
+ label: field.label,
47
+ value: getValueAtPath(config, field.path),
48
+ type: field.type,
49
+ }));
50
+ }
51
+
52
+ /**
53
+ * @param {object} config
54
+ * @param {Record<string, import("../config/env-overrides.mjs").ConfigValueSource>} [sources]
55
+ * @param {Record<string, string>} [envVars]
56
+ */
57
+ export function buildEnvAwareShowFields(config, sources, envVars) {
58
+ return listEnvAwareDisplayFields().map((field) => ({
59
+ path: field.path,
60
+ label: field.label,
61
+ value: getValueAtPath(config, field.path),
62
+ type: field.type,
63
+ source: sources?.[field.path] ?? "file",
64
+ envVar: envVars?.[field.path],
65
+ detail: formatConfigSourceDetail(sources, envVars, field.path, getValueAtPath(config, field.path)),
66
+ }));
67
+ }
68
+
69
+ /**
70
+ * @param {object} config
71
+ * @param {{ path?: string, json?: boolean, sources?: Record<string, string>, envVars?: Record<string, string> }} [options]
72
+ * @returns {{ exitCode: number, output: string, error?: string, suggestedCommand?: string }}
73
+ */
74
+ export function formatSettingsShow(config, { path, json = false, sources, envVars } = {}) {
75
+ if (path) {
76
+ const parsed = parseSettingPath(path);
77
+ if (!parsed.ok) {
78
+ const message = parsed.error;
79
+ if (json) {
80
+ return {
81
+ exitCode: 1,
82
+ output: `${JSON.stringify({ error: message }, null, 2)}\n`,
83
+ error: message,
84
+ };
85
+ }
86
+ return {
87
+ exitCode: 1,
88
+ output: `Error: ${message}\n`,
89
+ error: message,
90
+ };
91
+ }
92
+
93
+ const value = getValueAtPath(config, parsed.path);
94
+ const source = sources?.[parsed.path];
95
+ const envVar = envVars?.[parsed.path];
96
+ if (json) {
97
+ return {
98
+ exitCode: 0,
99
+ output: `${JSON.stringify({ path: parsed.path, value, source, envVar }, null, 2)}\n`,
100
+ };
101
+ }
102
+
103
+ const suffix =
104
+ source === "env" && envVar ? ` (${source}: ${envVar})` : source ? ` (${source})` : "";
105
+ return {
106
+ exitCode: 0,
107
+ output: `${formatSettingValue(value, parsed.field.type)}${suffix}\n`,
108
+ };
109
+ }
110
+
111
+ const envAwareFields = buildEnvAwareShowFields(config, sources, envVars);
112
+ const fields = buildSettingsShowFields(config);
113
+ if (json) {
114
+ return {
115
+ exitCode: 0,
116
+ output: `${JSON.stringify({ envAwareFields, fields }, null, 2)}\n`,
117
+ };
118
+ }
119
+
120
+ const lines = ["", "Effective config (env > file)", ""];
121
+ for (const field of envAwareFields) {
122
+ lines.push(`${field.path.padEnd(28)} ${field.label}: ${field.detail}`);
123
+ }
124
+ lines.push("", "Spine settings (editable via settings set)", "");
125
+ for (const field of fields) {
126
+ const source = sources?.[field.path];
127
+ const envVar = envVars?.[field.path];
128
+ const suffix =
129
+ source === "env" && envVar ? ` (${source}: ${envVar})` : source ? ` (${source})` : "";
130
+ lines.push(
131
+ `${field.path.padEnd(28)} ${field.label}: ${formatSettingValue(field.value, field.type)}${suffix}`,
132
+ );
133
+ }
134
+ lines.push("");
135
+
136
+ return {
137
+ exitCode: 0,
138
+ output: lines.join("\n"),
139
+ };
140
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * /spine-settings menu formatter and handler (FR-CFG-03).
3
+ */
4
+
5
+ import { loadSpineConfig } from "../../bin/spine-config.mjs";
6
+ import { runSpineSettingsSet } from "../../bin/spine-settings.mjs";
7
+ import { buildSettingsShowFields } from "./settings-show.mjs";
8
+
9
+ /**
10
+ * @param {unknown} value
11
+ * @param {string} type
12
+ */
13
+ function formatSettingValue(value, type) {
14
+ if (value === undefined || value === null) {
15
+ return "(not set)";
16
+ }
17
+ if (type === "boolean") {
18
+ return value ? "true" : "false";
19
+ }
20
+ if (type === "string" && value === "") {
21
+ return "(empty)";
22
+ }
23
+ return String(value);
24
+ }
25
+
26
+ /**
27
+ * @param {object} config
28
+ */
29
+ export function formatSettingsSlashMenu(config) {
30
+ const fields = buildSettingsShowFields(config);
31
+ const lines = ["Spine settings", ""];
32
+
33
+ for (const field of fields) {
34
+ const display = formatSettingValue(field.value, field.type);
35
+ lines.push(`${field.path}`);
36
+ lines.push(` ${field.label}: ${display}`);
37
+ lines.push(` → spine settings set ${field.path} <value>`);
38
+ lines.push("");
39
+ }
40
+
41
+ lines.push("Change from pi: /spine-settings set <path> <value>");
42
+ lines.push("Read-only CLI: spine settings show [path] [--json]");
43
+
44
+ return lines.join("\n");
45
+ }
46
+
47
+ /**
48
+ * @param {string} argsText
49
+ */
50
+ function parseSetArgs(argsText) {
51
+ const tokens = argsText.trim().split(/\s+/).filter(Boolean);
52
+ if (tokens.length === 0 || tokens[0] !== "set") {
53
+ return { error: "Usage: /spine-settings set <path> <value>" };
54
+ }
55
+
56
+ const positional = tokens.slice(1);
57
+ if (positional.length < 2) {
58
+ return { error: "Usage: /spine-settings set <path> <value>" };
59
+ }
60
+
61
+ const [settingPath, ...valueParts] = positional;
62
+ return { path: settingPath, rawValue: valueParts.join(" ") };
63
+ }
64
+
65
+ /**
66
+ * @param {string} args
67
+ * @param {{ notify: (message: string, level: string) => void }} ui
68
+ * @param {string} [cwd]
69
+ */
70
+ export async function runSpineSettingsSlash(args, ui, cwd = process.cwd()) {
71
+ const trimmed = args.trim();
72
+
73
+ if (trimmed === "set" || trimmed.startsWith("set ")) {
74
+ const parsed = parseSetArgs(trimmed);
75
+ if (parsed.error || !parsed.path || parsed.rawValue === undefined) {
76
+ ui.notify(parsed.error ?? "Usage: /spine-settings set <path> <value>", "error");
77
+ return;
78
+ }
79
+
80
+ const result = runSpineSettingsSet({
81
+ projectRoot: cwd,
82
+ args: [parsed.path, parsed.rawValue],
83
+ });
84
+
85
+ if (result.exitCode !== 0) {
86
+ ui.notify(result.output.trim() || "spine settings set failed", "error");
87
+ return;
88
+ }
89
+
90
+ ui.notify(result.output.trim() || `Updated ${parsed.path}`, "info");
91
+ return;
92
+ }
93
+
94
+ const configResult = loadSpineConfig(cwd);
95
+ if (configResult.error) {
96
+ const suggested = configResult.error.suggestedCommand ?? "spine init";
97
+ ui.notify(
98
+ `${configResult.error.message}
99
+
100
+ → ${suggested}`,
101
+ "error",
102
+ );
103
+ return;
104
+ }
105
+
106
+ ui.notify(formatSettingsSlashMenu(configResult.config), "info");
107
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * contract.mode config validation (SP-142, handoff §3.1).
3
+ */
4
+
5
+ /** @type {readonly string[]} */
6
+ export const CONTRACT_MODES = Object.freeze(["required", "optional", "legacy"]);
7
+
8
+ /**
9
+ * @param {unknown} config
10
+ * @returns {{ code: string, message: string, suggestedCommand: string } | null}
11
+ */
12
+ export function validateContractConfig(config) {
13
+ if (config?.contract == null) {
14
+ return null;
15
+ }
16
+
17
+ const contract = config.contract;
18
+ if (typeof contract !== "object" || contract === null || Array.isArray(contract)) {
19
+ return {
20
+ code: "CONFIG_CONTRACT_INVALID",
21
+ message: "contract must be an object when set",
22
+ suggestedCommand: "spine init --force",
23
+ };
24
+ }
25
+
26
+ if (contract.mode != null) {
27
+ if (typeof contract.mode !== "string" || !CONTRACT_MODES.includes(contract.mode)) {
28
+ return {
29
+ code: "CONFIG_CONTRACT_MODE_INVALID",
30
+ message: `contract.mode must be one of: ${CONTRACT_MODES.join(", ")}`,
31
+ suggestedCommand: "spine settings set contract.mode required",
32
+ };
33
+ }
34
+ }
35
+
36
+ if (contract.legacyTaskIdPrefixes != null) {
37
+ if (!Array.isArray(contract.legacyTaskIdPrefixes)) {
38
+ return {
39
+ code: "CONFIG_CONTRACT_LEGACY_INVALID",
40
+ message: "contract.legacyTaskIdPrefixes must be an array of strings when set",
41
+ suggestedCommand: "spine settings set contract.legacyTaskIdPrefixes '[\"TP-\"]'",
42
+ };
43
+ }
44
+ for (const entry of contract.legacyTaskIdPrefixes) {
45
+ if (typeof entry !== "string" || !entry.trim()) {
46
+ return {
47
+ code: "CONFIG_CONTRACT_LEGACY_INVALID",
48
+ message: "contract.legacyTaskIdPrefixes entries must be non-empty strings",
49
+ suggestedCommand: "spine settings set contract.legacyTaskIdPrefixes '[\"TP-\"]'",
50
+ };
51
+ }
52
+ }
53
+ }
54
+
55
+ return null;
56
+ }