@seanmars/tospec 0.12.0 → 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.
- package/CHANGELOG.md +233 -0
- package/README.md +20 -7
- package/assets/dashboard/app.js +6 -0
- package/assets/dashboard/style.css +42 -5
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +39 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +21 -16
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/dashboard.d.ts +95 -8
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +256 -31
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +1 -13
- package/dist/commands/decision.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +80 -44
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/workflow/instructions.d.ts +0 -2
- package/dist/commands/workflow/instructions.d.ts.map +1 -1
- package/dist/commands/workflow/instructions.js +3 -38
- package/dist/commands/workflow/instructions.js.map +1 -1
- package/dist/commands/workflow/shared.d.ts +0 -3
- package/dist/commands/workflow/shared.d.ts.map +1 -1
- package/dist/commands/workflow/shared.js.map +1 -1
- package/dist/core/archive.d.ts +11 -2
- package/dist/core/archive.d.ts.map +1 -1
- package/dist/core/archive.js +110 -111
- package/dist/core/archive.js.map +1 -1
- package/dist/core/artifact-graph/instruction-loader.d.ts +0 -5
- package/dist/core/artifact-graph/instruction-loader.d.ts.map +1 -1
- package/dist/core/artifact-graph/instruction-loader.js +37 -40
- package/dist/core/artifact-graph/instruction-loader.js.map +1 -1
- package/dist/core/artifact-graph/resolver.d.ts +27 -1
- package/dist/core/artifact-graph/resolver.d.ts.map +1 -1
- package/dist/core/artifact-graph/resolver.js +114 -127
- package/dist/core/artifact-graph/resolver.js.map +1 -1
- package/dist/core/artifact-graph/schema.d.ts.map +1 -1
- package/dist/core/artifact-graph/schema.js +22 -0
- package/dist/core/artifact-graph/schema.js.map +1 -1
- package/dist/core/change-metadata/schema.d.ts +1 -0
- package/dist/core/change-metadata/schema.d.ts.map +1 -1
- package/dist/core/change-metadata/schema.js +7 -0
- package/dist/core/change-metadata/schema.js.map +1 -1
- package/dist/core/change-presenter.d.ts +0 -1
- package/dist/core/change-presenter.d.ts.map +1 -1
- package/dist/core/change-presenter.js +4 -21
- package/dist/core/change-presenter.js.map +1 -1
- package/dist/core/command-generation/adapters/index.d.ts +9 -1
- package/dist/core/command-generation/adapters/index.d.ts.map +1 -1
- package/dist/core/command-generation/adapters/index.js +10 -1
- package/dist/core/command-generation/adapters/index.js.map +1 -1
- package/dist/core/command-generation/index.d.ts +2 -2
- package/dist/core/command-generation/index.d.ts.map +1 -1
- package/dist/core/command-generation/index.js +2 -2
- package/dist/core/command-generation/index.js.map +1 -1
- package/dist/core/config.d.ts +0 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +0 -4
- package/dist/core/config.js.map +1 -1
- package/dist/core/converters/json-converter.d.ts +0 -1
- package/dist/core/converters/json-converter.d.ts.map +1 -1
- package/dist/core/converters/json-converter.js +3 -17
- package/dist/core/converters/json-converter.js.map +1 -1
- package/dist/core/dashboard-activity.d.ts.map +1 -1
- package/dist/core/dashboard-activity.js +2 -8
- package/dist/core/dashboard-activity.js.map +1 -1
- package/dist/core/dashboard-data.d.ts +12 -6
- package/dist/core/dashboard-data.d.ts.map +1 -1
- package/dist/core/dashboard-data.js +13 -44
- package/dist/core/dashboard-data.js.map +1 -1
- package/dist/core/global-config.d.ts +59 -16
- package/dist/core/global-config.d.ts.map +1 -1
- package/dist/core/global-config.js +99 -41
- package/dist/core/global-config.js.map +1 -1
- package/dist/core/id.d.ts +0 -8
- package/dist/core/id.d.ts.map +1 -1
- package/dist/core/id.js +0 -19
- package/dist/core/id.js.map +1 -1
- package/dist/core/init.d.ts +0 -1
- package/dist/core/init.d.ts.map +1 -1
- package/dist/core/init.js +13 -23
- package/dist/core/init.js.map +1 -1
- package/dist/core/list.d.ts.map +1 -1
- package/dist/core/list.js +3 -34
- package/dist/core/list.js.map +1 -1
- package/dist/core/migrate.js +9 -15
- package/dist/core/migrate.js.map +1 -1
- package/dist/core/parsers/markdown-parser.d.ts +11 -1
- package/dist/core/parsers/markdown-parser.d.ts.map +1 -1
- package/dist/core/parsers/markdown-parser.js +25 -13
- package/dist/core/parsers/markdown-parser.js.map +1 -1
- package/dist/core/planning-home.d.ts +6 -0
- package/dist/core/planning-home.d.ts.map +1 -1
- package/dist/core/planning-home.js +6 -1
- package/dist/core/planning-home.js.map +1 -1
- package/dist/core/project-config.d.ts +17 -26
- package/dist/core/project-config.d.ts.map +1 -1
- package/dist/core/project-config.js +24 -138
- package/dist/core/project-config.js.map +1 -1
- package/dist/core/root-selection.d.ts.map +1 -1
- package/dist/core/root-selection.js +2 -15
- package/dist/core/root-selection.js.map +1 -1
- package/dist/core/shared/index.d.ts +1 -1
- package/dist/core/shared/index.d.ts.map +1 -1
- package/dist/core/shared/index.js +1 -1
- package/dist/core/shared/index.js.map +1 -1
- package/dist/core/shared/skill-generation.js +3 -3
- package/dist/core/shared/skill-generation.js.map +1 -1
- package/dist/core/shared/tool-detection.d.ts +9 -6
- package/dist/core/shared/tool-detection.d.ts.map +1 -1
- package/dist/core/shared/tool-detection.js +9 -9
- package/dist/core/shared/tool-detection.js.map +1 -1
- package/dist/core/spec-presenter.d.ts.map +1 -1
- package/dist/core/spec-presenter.js.map +1 -1
- package/dist/core/specs-apply.d.ts +0 -31
- package/dist/core/specs-apply.d.ts.map +1 -1
- package/dist/core/specs-apply.js +0 -102
- package/dist/core/specs-apply.js.map +1 -1
- package/dist/core/templates/fragments/verify.d.ts +12 -11
- package/dist/core/templates/fragments/verify.d.ts.map +1 -1
- package/dist/core/templates/fragments/verify.js +22 -15
- package/dist/core/templates/fragments/verify.js.map +1 -1
- package/dist/core/templates/workflows/apply.d.ts +2 -2
- package/dist/core/templates/workflows/apply.js +10 -10
- package/dist/core/templates/workflows/apply.js.map +1 -1
- package/dist/core/templates/workflows/archive.d.ts.map +1 -1
- package/dist/core/templates/workflows/archive.js +30 -20
- package/dist/core/templates/workflows/archive.js.map +1 -1
- package/dist/core/templates/workflows/propose.js +2 -2
- package/dist/core/templates/workflows/sync.d.ts +4 -3
- package/dist/core/templates/workflows/sync.d.ts.map +1 -1
- package/dist/core/templates/workflows/sync.js +30 -13
- package/dist/core/templates/workflows/sync.js.map +1 -1
- package/dist/core/templates/workflows/update.js +1 -1
- package/dist/core/update.d.ts.map +1 -1
- package/dist/core/update.js +10 -15
- package/dist/core/update.js.map +1 -1
- package/dist/core/user-state-migration.d.ts +58 -0
- package/dist/core/user-state-migration.d.ts.map +1 -0
- package/dist/core/user-state-migration.js +107 -0
- package/dist/core/user-state-migration.js.map +1 -0
- package/dist/core/validation/section-validator.d.ts.map +1 -1
- package/dist/core/validation/section-validator.js +3 -16
- package/dist/core/validation/section-validator.js.map +1 -1
- package/dist/core/validation/validator.d.ts +0 -9
- package/dist/core/validation/validator.d.ts.map +1 -1
- package/dist/core/validation/validator.js +86 -115
- package/dist/core/validation/validator.js.map +1 -1
- package/dist/utils/change-metadata.d.ts +18 -0
- package/dist/utils/change-metadata.d.ts.map +1 -1
- package/dist/utils/change-metadata.js +39 -0
- package/dist/utils/change-metadata.js.map +1 -1
- package/dist/utils/change-utils.d.ts.map +1 -1
- package/dist/utils/change-utils.js +3 -6
- package/dist/utils/change-utils.js.map +1 -1
- package/dist/utils/file-system.d.ts +17 -19
- package/dist/utils/file-system.d.ts.map +1 -1
- package/dist/utils/file-system.js +41 -189
- package/dist/utils/file-system.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +22 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +39 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/item-discovery.d.ts +7 -0
- package/dist/utils/item-discovery.d.ts.map +1 -1
- package/dist/utils/item-discovery.js +13 -23
- package/dist/utils/item-discovery.js.map +1 -1
- package/dist/utils/link.d.ts +3 -1
- package/dist/utils/link.d.ts.map +1 -1
- package/dist/utils/link.js +4 -14
- package/dist/utils/link.js.map +1 -1
- package/dist/utils/spec-files.d.ts +19 -0
- package/dist/utils/spec-files.d.ts.map +1 -0
- package/dist/utils/spec-files.js +44 -0
- package/dist/utils/spec-files.js.map +1 -0
- package/dist/utils/task-progress.d.ts +0 -1
- package/dist/utils/task-progress.d.ts.map +1 -1
- package/dist/utils/task-progress.js +5 -6
- package/dist/utils/task-progress.js.map +1 -1
- package/package.json +11 -2
- package/schemas/issue/schema.yaml +6 -3
- package/schemas/sdd/schema.yaml +15 -2
- package/dist/core/references.d.ts +0 -40
- package/dist/core/references.d.ts.map +0 -1
- package/dist/core/references.js +0 -11
- package/dist/core/references.js.map +0 -1
- package/dist/utils/command-references.d.ts +0 -18
- package/dist/utils/command-references.d.ts.map +0 -1
- package/dist/utils/command-references.js +0 -20
- package/dist/utils/command-references.js.map +0 -1
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -9
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/shell-detection.d.ts +0 -20
- package/dist/utils/shell-detection.d.ts.map +0 -1
- package/dist/utils/shell-detection.js +0 -41
- package/dist/utils/shell-detection.js.map +0 -1
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Verify methodology — apply's
|
|
2
|
+
* Verify methodology — apply's opt-in review.
|
|
3
3
|
*
|
|
4
|
-
* verify is not a standalone skill/command; it
|
|
5
|
-
*
|
|
6
|
-
* lines of end-of-run review in front of an agent
|
|
7
|
-
* so the skill form discloses it to a sibling
|
|
8
|
-
* pointer. The command form has no sibling file,
|
|
9
|
-
* Either way this module is the single source of
|
|
4
|
+
* verify is not a standalone skill/command; it lives inside both apply variants
|
|
5
|
+
* and runs only when the user asks for it. The methodology is long enough that
|
|
6
|
+
* leaving it inline puts ~45 lines of end-of-run review in front of an agent
|
|
7
|
+
* that is still on task 1 of N, so the skill form discloses it to a sibling
|
|
8
|
+
* `VERIFY.md` and keeps only a pointer. The command form has no sibling file,
|
|
9
|
+
* so it inlines the same text. Either way this module is the single source of
|
|
10
|
+
* truth.
|
|
10
11
|
*/
|
|
11
12
|
/** The review protocol itself — shared by the disclosed file and the command. */
|
|
12
13
|
export const VERIFY_METHODOLOGY = `Two-axis review of the implementation, run as **independent parallel subagents** so neither pollutes or reranks the other's findings — a change can pass one axis and fail the other, and reporting them separately is what keeps that visible.
|
|
13
14
|
|
|
14
15
|
**Scope — two subagents, one pass each, and that is the whole review.** The subject under review is always the *code diff*, never another review's output. Do not spawn a third agent to grade the two axes' findings, do not re-review a report you have already written, do not audit the audit. Right-sized review beats deep review: enough eyes to catch real problems, no recursion for its own sake.
|
|
15
16
|
|
|
17
|
+
**What counts as blocking.** Exactly two kinds of finding block: a **hard violation** of a convention this repo documents, and a **spec-correctness** problem — a requirement missing, implemented wrongly, or contradicting a decision \`design.md\` records. Everything else — judgement calls, style preferences, and every code smell named below — is **report-only**: report it, do not fix it, and do not re-review because of it. A report-only finding is the user's call to make later, not this run's work. Leave this unstated and the safe reading is to fix everything, which makes "re-run only the affected axis" fire on every axis, every time.
|
|
18
|
+
|
|
16
19
|
**Steps**
|
|
17
20
|
|
|
18
21
|
1. **Gather context**
|
|
@@ -43,28 +46,32 @@ export const VERIFY_METHODOLOGY = `Two-axis review of the implementation, run as
|
|
|
43
46
|
|
|
44
47
|
**Verify output**
|
|
45
48
|
|
|
46
|
-
Report the two-axis result plus test suite status. If both axes are clean and tests are green, the change is verified — tell the user it's ready for \`tospec-archive\`. If either axis has a blocking finding or tests are red, do **not** treat apply as done: fix the issue here (this is still apply)
|
|
49
|
+
Report the two-axis result plus test suite status. If both axes are clean and tests are green, the change is verified — tell the user it's ready for \`tospec-archive\`. If either axis has a blocking finding or tests are red, do **not** treat apply as done: fix the issue here (this is still apply), then send **only the hunk that fixed it** back to the axis that reported it — never the whole axis, and never the other one. You are reviewing the changed code, not the previous report. A clean axis is not re-run for extra confidence.
|
|
47
50
|
|
|
48
51
|
**Verify guardrails**
|
|
49
52
|
- Standards and Spec axes are independent — never let one axis's findings influence the other's report
|
|
50
53
|
- Full test suite must be green; a clean review with red tests is not verified
|
|
51
54
|
- Quote the specific spec/task line or hunk for every finding — no unsupported claims
|
|
52
|
-
- **One review pass per axis — never review the review.** No agent audits another agent's findings, no re-reviewing a report you already wrote; a re-run after a fix
|
|
55
|
+
- **One review pass per axis — never review the review.** No agent audits another agent's findings, no re-reviewing a report you already wrote; a re-run after a fix sees only the hunk that fixed it, and a clean axis is not re-run for extra confidence`;
|
|
53
56
|
/** Contents of the `VERIFY.md` shipped beside each apply skill's `SKILL.md`. */
|
|
54
|
-
export const VERIFY_DOC = `# Verify — apply's
|
|
57
|
+
export const VERIFY_DOC = `# Verify — apply's opt-in review
|
|
55
58
|
|
|
56
|
-
Run this once every task in the tracks file is checked off and \`tospec validate\` passes. It is
|
|
59
|
+
Run this **when the user asks for a review**, once every task in the tracks file is checked off and \`tospec validate\` passes. It is not a step apply reaches on its own.
|
|
57
60
|
|
|
58
61
|
${VERIFY_METHODOLOGY}
|
|
59
62
|
`;
|
|
60
63
|
/** The pointer that replaces the methodology inside the apply skills. */
|
|
61
|
-
export const VERIFY_POINTER = `## Verify (
|
|
64
|
+
export const VERIFY_POINTER = `## Verify (opt-in — only when the user asks)
|
|
65
|
+
|
|
66
|
+
The two-axis review does **not** run on its own. Apply finishes on the full test suite and \`tospec validate\`; a change with those green is implemented, review or no review.
|
|
62
67
|
|
|
63
|
-
|
|
68
|
+
When the user asks for a review, **read \`VERIFY.md\` in this skill's directory and run it in full.** Don't offer it unprompted either — no "shall I review this?" at the end of a run. If a review does run, the change stays unfinished — and must not go to \`tospec-archive\` — until it comes back clean.`;
|
|
64
69
|
/** The same block for the command form, which has no sibling file to point at. */
|
|
65
|
-
export const VERIFY_INLINE = `## Verify (
|
|
70
|
+
export const VERIFY_INLINE = `## Verify (opt-in — only when the user asks)
|
|
71
|
+
|
|
72
|
+
The two-axis review does **not** run on its own. Apply finishes on the full test suite and \`tospec validate\`; a change with those green is implemented, review or no review.
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
When the user asks for a review, run the methodology below in full. Don't offer it unprompted either — no "shall I review this?" at the end of a run. If a review does run, the change stays unfinished — and must not go to \`tospec-archive\` — until it comes back clean.
|
|
68
75
|
|
|
69
76
|
${VERIFY_METHODOLOGY}`;
|
|
70
77
|
//# sourceMappingURL=verify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../../src/core/templates/fragments/verify.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../../src/core/templates/fragments/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2PA0CyN,CAAC;AAE5P,gFAAgF;AAChF,MAAM,CAAC,MAAM,UAAU,GAAG;;;;EAIxB,kBAAkB;CACnB,CAAC;AAEF,yEAAyE;AACzE,MAAM,CAAC,MAAM,cAAc,GAAG;;;;+SAIiR,CAAC;AAEhT,kFAAkF;AAClF,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;EAM3B,kBAAkB,EAAE,CAAC"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This file is generated by splitting the legacy monolithic
|
|
5
5
|
* templates file into workflow-focused modules.
|
|
6
6
|
*
|
|
7
|
-
* Two apply variants share the same gating (`applyRequires`),
|
|
8
|
-
*
|
|
7
|
+
* Two apply variants share the same gating (`applyRequires`), opt-in verify
|
|
8
|
+
* section, and re-validate step; they differ only in how tests relate to the
|
|
9
9
|
* implementation:
|
|
10
10
|
* - `tospec-apply` — default, tests optional (write one when it earns its keep)
|
|
11
11
|
* - `tospec-apply-with-tdd` — strict TDD, red → green per slice
|
|
@@ -23,7 +23,7 @@ function buildApplyBody(v, verifySection) {
|
|
|
23
23
|
|
|
24
24
|
Act on \`state\`:
|
|
25
25
|
- \`blocked\` — required artifacts or the tracks file are missing; show \`instruction\` and STOP, sending the user back to \`tospec-propose\`/\`tospec-issue\`.
|
|
26
|
-
- \`all_done\` — everything is checked off already;
|
|
26
|
+
- \`all_done\` — everything is checked off already; say so and stop. A change being complete is not by itself a reason to review it.
|
|
27
27
|
- \`ready\` — proceed.
|
|
28
28
|
|
|
29
29
|
3. **Read the context files**
|
|
@@ -58,7 +58,7 @@ ${verifySection}
|
|
|
58
58
|
|
|
59
59
|
**Output**
|
|
60
60
|
|
|
61
|
-
Report which tasks/checkboxes completed this pass, current progress (\`tospec status --change "<name>"\`), and whether all required artifacts are checked off. When everything is done
|
|
61
|
+
Report which tasks/checkboxes completed this pass, current progress (\`tospec status --change "<name>"\`), and whether all required artifacts are checked off. When everything is done and the test suite is green, tell the user the change is ready for \`tospec-archive\`. If they asked for a review and it surfaced findings it defines as blocking, keep working here to resolve them.
|
|
62
62
|
|
|
63
63
|
**Guardrails**
|
|
64
64
|
${v.guardrailsHead}
|
|
@@ -68,7 +68,7 @@ ${v.guardrailsHead}
|
|
|
68
68
|
- Keep code changes minimal and scoped to the item at hand
|
|
69
69
|
- Any test you do write goes at the pre-agreed seam (design.md for sdd; the existing/new seam identified for issue) — never against internals
|
|
70
70
|
- Fix root cause: check every caller of a shared function before declaring a fix complete
|
|
71
|
-
- Don't hand off to archive until the
|
|
71
|
+
- Don't hand off to archive until the full test suite is green — and, when a review was requested, until it comes back clean`;
|
|
72
72
|
}
|
|
73
73
|
// -----------------------------------------------------------------------------
|
|
74
74
|
// Default apply — implement per slice; tests are optional, not mandated
|
|
@@ -80,7 +80,7 @@ const APPLY_VARIANT = {
|
|
|
80
80
|
For each tracer-bullet slice in \`tasks.md\`:
|
|
81
81
|
1. Implement the minimum that satisfies the behavior the slice's specs describe. Don't anticipate future slices or add speculative flexibility.
|
|
82
82
|
2. Verify the result matches the behavior the slice's specs describe, and that the existing test suite still passes.
|
|
83
|
-
3. Check off the slice, then move to the next one — one slice per cycle. Refactoring is not part of this loop; it
|
|
83
|
+
3. Check off the slice, then move to the next one — one slice per cycle. Refactoring is not part of this loop; raise it separately once the slice is green.
|
|
84
84
|
|
|
85
85
|
Writing a new test is **not required** in this loop — add one when it earns its keep. If you do, put it at the seam \`design.md\` named and don't test internals or add implementation-coupled assertions (mocking internal collaborators, reaching into private state, checking the database instead of the interface).`,
|
|
86
86
|
issueBranch: `### issue branch — fix root cause
|
|
@@ -97,8 +97,8 @@ const APPLY_BODY_COMMAND = buildApplyBody(APPLY_VARIANT, VERIFY_INLINE);
|
|
|
97
97
|
export function getTospecApplySkillTemplate() {
|
|
98
98
|
return {
|
|
99
99
|
name: 'tospec-apply',
|
|
100
|
-
description: "Implement a tospec change's tasks slice by slice (tests optional)
|
|
101
|
-
instructions: `Implement a change's tasks one slice at a time, branching by schema
|
|
100
|
+
description: "Implement a tospec change's tasks slice by slice (tests optional). Use when the user wants to start or continue implementing a change.",
|
|
101
|
+
instructions: `Implement a change's tasks one slice at a time, branching by schema — ready for \`tospec-archive\` once the tasks are done and the tests are green. The two-axis review is opt-in: it runs only if the user asks for it.
|
|
102
102
|
|
|
103
103
|
**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
104
104
|
|
|
@@ -116,7 +116,7 @@ export function getTospecApplyCommandTemplate() {
|
|
|
116
116
|
description: 'Implement tasks from a change, one slice at a time',
|
|
117
117
|
category: 'Workflow',
|
|
118
118
|
tags: ['workflow', 'implementation'],
|
|
119
|
-
content: `Implement a change's tasks one slice at a time, branching by schema
|
|
119
|
+
content: `Implement a change's tasks one slice at a time, branching by schema — ready for \`tospec-archive\` once the tasks are done and the tests are green. The two-axis review is opt-in: it runs only if the user asks for it.
|
|
120
120
|
|
|
121
121
|
**Input**: Optionally specify a change name after \`tospec-apply\` (e.g., \`tospec-apply add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
122
122
|
|
|
@@ -134,7 +134,7 @@ For each tracer-bullet slice in \`tasks.md\`:
|
|
|
134
134
|
1. Write the failing test first (red) — **only at the seam \`design.md\` named**. Don't test internals, don't add implementation-coupled assertions (mocking internal collaborators, reaching into private state, checking the database instead of the interface).
|
|
135
135
|
2. Implement the minimum to pass (green). Don't anticipate future slices or add speculative flexibility.
|
|
136
136
|
3. Verify the result matches the behavior the slice's specs describe.
|
|
137
|
-
4. Check off the slice, then move to the next one — one slice per cycle. Refactoring is not part of this loop; it
|
|
137
|
+
4. Check off the slice, then move to the next one — one slice per cycle. Refactoring is not part of this loop; raise it separately once the slice is green.`,
|
|
138
138
|
issueBranch: `### issue branch — three-way test split
|
|
139
139
|
|
|
140
140
|
Read \`task.md\`'s feedback loop. Then:
|
|
@@ -152,7 +152,7 @@ export function getTospecApplyWithTDDSkillTemplate() {
|
|
|
152
152
|
return {
|
|
153
153
|
name: 'tospec-apply-with-tdd',
|
|
154
154
|
description: 'Implement tasks from a tospec change test-first (red → green). Use when the user wants to start or continue implementation with a strict TDD loop.',
|
|
155
|
-
instructions: `Implement a change's tasks test-first (red → green), one slice at a time, branching by schema
|
|
155
|
+
instructions: `Implement a change's tasks test-first (red → green), one slice at a time, branching by schema — ready for \`tospec-archive\` once the tasks are done and the tests are green. The two-axis review is opt-in: it runs only if the user asks for it.
|
|
156
156
|
|
|
157
157
|
**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
158
158
|
|
|
@@ -170,7 +170,7 @@ export function getTospecApplyWithTDDCommandTemplate() {
|
|
|
170
170
|
description: 'Implement tasks from a change test-first (red → green)',
|
|
171
171
|
category: 'Workflow',
|
|
172
172
|
tags: ['workflow', 'tdd', 'implementation'],
|
|
173
|
-
content: `Implement a change's tasks test-first (red → green), one slice at a time, branching by schema
|
|
173
|
+
content: `Implement a change's tasks test-first (red → green), one slice at a time, branching by schema — ready for \`tospec-archive\` once the tasks are done and the tests are green. The two-axis review is opt-in: it runs only if the user asks for it.
|
|
174
174
|
|
|
175
175
|
**Input**: Optionally specify a change name after \`tospec-apply-with-tdd\` (e.g., \`tospec-apply-with-tdd add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
176
176
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../src/core/templates/workflows/apply.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAiBnF;;;GAGG;AACH,uEAAuE;AACvE,SAAS,cAAc,CAAC,CAAe,EAAE,aAAqB;IAC5D,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEA+B0D,CAAC,CAAC,YAAY;;;;;;;;EAQ/E,CAAC,CAAC,SAAS;;EAEX,CAAC,CAAC,WAAW;;;;;;;;EAQb,aAAa;;;;;;;EAOb,CAAC,CAAC,cAAc;;;;;;;
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../src/core/templates/workflows/apply.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAiBnF;;;GAGG;AACH,uEAAuE;AACvE,SAAS,cAAc,CAAC,CAAe,EAAE,aAAqB;IAC5D,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEA+B0D,CAAC,CAAC,YAAY;;;;;;;;EAQ/E,CAAC,CAAC,SAAS;;EAEX,CAAC,CAAC,WAAW;;;;;;;;EAQb,aAAa;;;;;;;EAOb,CAAC,CAAC,cAAc;;;;;;;6HAO2G,CAAC;AAC9H,CAAC;AAED,gFAAgF;AAChF,wEAAwE;AACxE,gFAAgF;AAEhF,MAAM,aAAa,GAAiB;IAClC,YAAY,EACV,8IAA8I;IAChJ,SAAS,EAAE;;;;;;;yTAO4S;IACvT,WAAW,EAAE;;;;oJAIqI;IAClJ,cAAc,EAAE;;wFAEsE;CACvF,CAAC;AAEF,MAAM,UAAU,GAAG,cAAc,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AACjE,MAAM,kBAAkB,GAAG,cAAc,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAExE,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,wIAAwI;QACrJ,YAAY,EAAE;;;;EAIhB,UAAU,EAAE;QACV,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,sBAAsB;QACrC,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAAC;QAC3F,UAAU,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE;KACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,oDAAoD;QACjE,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,CAAC,UAAU,EAAE,gBAAgB,CAAC;QACpC,OAAO,EAAE;;;;EAIX,kBAAkB,EAAE;KACnB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,2CAA2C;AAC3C,gFAAgF;AAEhF,MAAM,iBAAiB,GAAiB;IACtC,YAAY,EACV,sIAAsI;IACxI,SAAS,EAAE;;;;;;4JAM+I;IAC1J,WAAW,EAAE;;;;;;;wMAOyL;IACtM,cAAc,EAAE;yCACuB;CACxC,CAAC;AAEF,MAAM,cAAc,GAAG,cAAc,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;AACzE,MAAM,sBAAsB,GAAG,cAAc,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAEhF,MAAM,UAAU,kCAAkC;IAChD,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,oJAAoJ;QACjK,YAAY,EAAE;;;;EAIhB,cAAc,EAAE;QACd,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,sBAAsB;QACrC,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC9B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAAC;QAC3F,UAAU,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE;KACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oCAAoC;IAClD,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,wDAAwD;QACrE,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,gBAAgB,CAAC;QAC3C,OAAO,EAAE;;;;EAIX,sBAAsB,EAAE;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../../../src/core/templates/workflows/archive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../../../src/core/templates/workflows/archive.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2DlE,wBAAgB,6BAA6B,IAAI,aAAa,CAc7D;AAED,wBAAgB,+BAA+B,IAAI,eAAe,CAYjE"}
|
|
@@ -1,54 +1,64 @@
|
|
|
1
|
-
const ARCHIVE_BODY = `**Finishing a change:
|
|
1
|
+
const ARCHIVE_BODY = `**Finishing a change: sync, then archive — in that order.** Do not run \`tospec archive\` speculatively "to see what happens"; each step below must actually hold first.
|
|
2
2
|
|
|
3
|
-
**Step
|
|
3
|
+
**Step 1 — run the sync, don't ask about it**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Archive merges the change's delta specs into \`tospec/specs/\` permanently, so if those specs have drifted from what the code actually does, archiving locks in a description that no longer matches reality. Decide **proactively** whether that risk applies here:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Take these in order; the first that matches wins.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
1. **The user explicitly asked to skip it** ("archive without syncing", "just archive") — honor that. Skip the sync and archive **without** \`--require-sync\` (Step 2, not-synced branch). This is checked first on purpose: an explicit instruction outranks the default, and what was removed is the unsolicited question, not the user's authority.
|
|
10
|
+
2. **No delta specs at all** (e.g. a purely cosmetic issue fix with no behavior change) — there is no spec-vs-code drift to find. Skip straight to Step 2 and archive directly. Under a schema that requires deltas (sdd), such a change also needs \`skip_specs: true\` in its \`.tospec.yaml\` or validation will refuse it — set that once, and only when the change truly has no externally observable effect. Never write a delta spec just to get past the gate.
|
|
11
|
+
3. **Otherwise the change produced delta specs** (a non-empty \`specs/<capability>/spec.md\` under the change dir), so behavior was added or changed and drift is possible. Run the \`tospec-sync\` workflow now, without asking. There is no question to put: declining would mean knowingly publishing a spec that may not describe the code, so a prompt here spends the user's attention without buying a decision.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- **Sync is not needed** when there are no delta specs at all (e.g. a purely cosmetic issue fix with no behavior change). In that case skip straight to Step 2 and archive directly — don't ask a pointless question.
|
|
13
|
+
Running it unannounced is safe because of how \`tospec-sync\` is ordered: it judges every Requirement before writing anything, so a defect surfaces while the working tree is still untouched.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
**Step 1a — read the sync's verdict and branch**
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
- **Every Requirement MATCH, or SPEC-UPDATED** (the spec was stale, sync corrected it to match the code and re-validated) → continue to Step 2, synced branch. **Ask nothing** — a corrected spec is the workflow working as intended, not a decision point.
|
|
18
|
+
- **Any CODE-BUG** (the implementation doesn't do what a Requirement describes, or was never built) → \`sync-report.md\` says \`Conclusion: FAIL\` and **no spec file was written**. This is the one place archive stops. **Ask the user exactly once:**
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
> "Sync found <N> Requirement(s) the code doesn't satisfy: <names>. Fix them now, or leave it for later?"
|
|
21
|
+
|
|
22
|
+
- **Fix now** → hand off to \`tospec-apply\` for the fix. Archive does not edit source itself. On return, resume \`tospec-sync\` **at step 4** with the verdicts it already produced — do not re-run steps 1-3. Concretely: re-judge **only the Requirements that were reported as defects** (not the whole set, and not the ones already judged MATCH), and once none of them is still a CODE-BUG, run step 4's write phase over **every** SPEC-UPDATED verdict, including the ones sync held back when it stopped. Sync then rewrites \`sync-report.md\` with \`Conclusion: PASS\`. Only then continue to Step 2 — the gate reads that report, so an un-rewritten FAIL will (correctly) refuse.
|
|
23
|
+
- **Later** → stop. Do not archive; the change stays active with its spec files unmodified.
|
|
24
|
+
|
|
25
|
+
If the re-judge finds a Requirement is *still* a CODE-BUG, do **not** put the question again — it was already answered. Report which Requirement did not come clean and stop, as for "Later". The one-question rule is per archive run, not per attempt.
|
|
26
|
+
|
|
27
|
+
- **\`Conclusion: FAIL\` with no CODE-BUG** — validation failed somewhere sync could not resolve: either on a spec update it had just written (the report names that Requirement) or on the final artifact check, which can fail on an artifact no Requirement touched. Either way this is an artifact problem, not a code defect: fix whatever \`tospec validate --json\` points at — the report names it when a spec update caused it — then re-run validation and have sync complete any remaining writes and rewrite the report to PASS. Do not archive on a FAIL report, and do not reach for \`--require-sync\`'s absence to route around it.
|
|
20
28
|
|
|
21
29
|
**Step 2 — archive**
|
|
22
30
|
|
|
23
|
-
Synced branch (
|
|
31
|
+
Synced branch (a sync ran and \`sync-report.md\` says \`Conclusion: PASS\`):
|
|
24
32
|
\`\`\`bash
|
|
25
33
|
tospec archive "<name>" --json --require-sync
|
|
26
34
|
\`\`\`
|
|
27
|
-
\`--require-sync\` is the CLI's own machine-checkable half of the sync gate: it refuses unless \`sync-report.md\` exists with a \`Conclusion: PASS\` line (\`SYNC_REPORT_MISSING\` / \`SYNC_REPORT_FAILED\`).
|
|
35
|
+
\`--require-sync\` is the CLI's own machine-checkable half of the sync gate: it refuses unless \`sync-report.md\` exists with a \`Conclusion: PASS\` line (\`SYNC_REPORT_MISSING\` / \`SYNC_REPORT_FAILED\`). Since the sync just ran and passed, this succeeds for free — a CLI-enforced backstop behind the instruction-level order above.
|
|
28
36
|
|
|
29
|
-
Not-synced branch (
|
|
37
|
+
Not-synced branch (no delta specs, or the user asked to skip):
|
|
30
38
|
\`\`\`bash
|
|
31
39
|
tospec archive "<name>" --json
|
|
32
40
|
\`\`\`
|
|
41
|
+
Only omit \`--require-sync\` on this branch; passing it without a sync having run will (correctly) refuse.
|
|
33
42
|
|
|
34
43
|
Either way, the CLI then: re-validates the delta specs (blocking), checks tasks/task completion (with \`--json\`, incomplete tasks block unless you pass \`--yes\` after the user confirms), does a two-phase atomic merge into \`tospec/specs/\` (dry-run + re-validate every target first, writes only if all pass), and moves the change directory — including \`sync-report.md\` when present — into \`tospec/changes/archive/\` under a \`yyyyMMdd_HHmmss-<name>\` timestamp the CLI generates itself.
|
|
35
44
|
|
|
36
45
|
**Reading the result**: the \`--json\` output is \`{archive, status}\`. Success → \`archive\` holds \`{change, archivedAs, path, specsUpdated}\`. Failure → \`archive\` is \`null\` and \`status[0].code\` tells you which ending you got: \`archive_validation_failed\` (fix artifacts, re-validate), \`archive_tasks_incomplete\` / \`archive_tasks_missing\` (ask the user, then rerun with \`--yes\` to override), \`SYNC_REPORT_MISSING\` / \`SYNC_REPORT_FAILED\` (the sync gate refused). Each status entry carries \`{code, message, fix}\` — follow \`fix\`.
|
|
37
46
|
|
|
38
47
|
**Guardrails — explicit and non-negotiable**
|
|
39
|
-
-
|
|
48
|
+
- Run the sync when the change has spec deltas; do not ask permission for it. Honor an explicit request to skip, and skip it outright when there are no delta specs
|
|
49
|
+
- A CODE-BUG is the only outcome that may interrupt — MATCH and SPEC-UPDATED continue silently. Never edit source from here; a fix goes through \`tospec-apply\`
|
|
40
50
|
- Only pass \`--require-sync\` when \`tospec-sync\` actually produced a passing \`sync-report.md\` this run
|
|
41
51
|
- **\`tospec archive\` owns the archive directory** — it generates the \`yyyyMMdd_HHmmss-<name>\` name and moves the change there. Let the command do it: the timestamp comes from internals you cannot reproduce, so a hand-built name risks a collision or a wrong sort order
|
|
42
52
|
- If \`tospec archive\` reports a validation failure or asks for confirmation on incomplete tasks, resolve the underlying issue (or explicitly confirm with the user) — do not route around it with manual file operations
|
|
43
53
|
|
|
44
54
|
**Output**
|
|
45
55
|
|
|
46
|
-
Report the archived name and path from \`tospec archive\`'s output, whether a sync ran, and
|
|
56
|
+
Report the archived name and path from \`tospec archive\`'s output, whether a sync ran and what it concluded, and **anything the sync found that no Requirement asked for** — that is reported here, never written into a spec, and never a reason to block. Confirm \`tospec/specs/\` now reflects the merged change.`;
|
|
47
57
|
export function getTospecArchiveSkillTemplate() {
|
|
48
58
|
return {
|
|
49
59
|
name: 'tospec-archive',
|
|
50
|
-
description: 'Finish and archive a completed tospec change via `tospec archive`,
|
|
51
|
-
instructions: `Finish a completed change:
|
|
60
|
+
description: 'Finish and archive a completed tospec change via `tospec archive`, running a spec/code sync first when the change has spec deltas. Use when the user wants to finalize an implemented change.',
|
|
61
|
+
instructions: `Finish a completed change: run \`tospec-sync\` when the change has spec deltas, then \`tospec archive\` — the only path to a merged, archived change.
|
|
52
62
|
|
|
53
63
|
**Input**: The user's request should name the change to archive.
|
|
54
64
|
|
|
@@ -62,10 +72,10 @@ ${ARCHIVE_BODY}`,
|
|
|
62
72
|
export function getTospecArchiveCommandTemplate() {
|
|
63
73
|
return {
|
|
64
74
|
name: 'TOSPEC: Archive',
|
|
65
|
-
description: '
|
|
75
|
+
description: 'Run a spec/code sync when warranted, then finalize and archive a completed change',
|
|
66
76
|
category: 'Workflow',
|
|
67
77
|
tags: ['workflow', 'archive'],
|
|
68
|
-
content: `Finish a completed change:
|
|
78
|
+
content: `Finish a completed change: run \`tospec-sync\` when the change has spec deltas, then \`tospec archive\` — the only path to a merged, archived change.
|
|
69
79
|
|
|
70
80
|
**Input**: The argument after \`tospec-archive\` is the change name to archive.
|
|
71
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive.js","sourceRoot":"","sources":["../../../../src/core/templates/workflows/archive.ts"],"names":[],"mappings":"AAQA,MAAM,YAAY,GAAG
|
|
1
|
+
{"version":3,"file":"archive.js","sourceRoot":"","sources":["../../../../src/core/templates/workflows/archive.ts"],"names":[],"mappings":"AAQA,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uTAuDkS,CAAC;AAExT,MAAM,UAAU,6BAA6B;IAC3C,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,+LAA+L;QAC5M,YAAY,EAAE;;;;EAIhB,YAAY,EAAE;QACZ,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,sBAAsB;QACrC,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC9B,YAAY,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC;KAC7F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,mFAAmF;QAChG,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC;QAC7B,OAAO,EAAE;;;;EAIX,YAAY,EAAE;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -22,7 +22,7 @@ const PROPOSE_BODY = `Do NOT re-interview the user — synthesize what's already
|
|
|
22
22
|
\`\`\`bash
|
|
23
23
|
tospec instructions <artifact-id> --change "<name>" --json
|
|
24
24
|
\`\`\`
|
|
25
|
-
Read \`template\` and \`instruction\` from the response, write \`resolvedOutputPath\`, then re-run \`status --json\` and continue until every \`applyRequires\` artifact is \`done\`.
|
|
25
|
+
Read \`template\` and \`instruction\` from the response, re-read every file listed under \`dependencies\` from disk (even ones you already saw — the user may have edited them since), write \`resolvedOutputPath\`, then re-run \`status --json\` and continue until every \`applyRequires\` artifact is \`done\`.
|
|
26
26
|
|
|
27
27
|
Artifact-specific rules on top of what \`instructions\` returns:
|
|
28
28
|
- **ticket** (already created): keep it thin — just refine the one-line \`## Summary\` so it names what this change does. All the detail (why, what, scope, decisions) lives in \`proposal.md\`, not here. Don't duplicate proposal content into the ticket, and don't add a timestamp or filename yourself.
|
|
@@ -44,7 +44,7 @@ Summarize the change name and location, the artifacts created, and prompt: "Run
|
|
|
44
44
|
- Create every artifact \`apply.requires\` needs — don't stop at \`proposal\`
|
|
45
45
|
- The ticket file and its timestamp are CLI-generated — never create, rename, or move ticket files; only edit the Summary in the existing stub
|
|
46
46
|
- Detailed why/what goes in \`proposal.md\`; the ticket stays a thin index
|
|
47
|
-
- Read dependency artifacts before writing the next one
|
|
47
|
+
- Read dependency artifacts from disk before writing the next one — don't rely on memory from earlier in the conversation, they may have been edited since
|
|
48
48
|
- \`context\`/\`rules\` from \`instructions\` are constraints for you, never content to copy into the file
|
|
49
49
|
- If a change with that name already exists, ask whether to continue it or pick a new name
|
|
50
50
|
- If context is critically unclear even after checking the conversation, ask — but prefer a reasonable default to keep momentum`;
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* This file is generated by splitting the legacy monolithic
|
|
5
5
|
* templates file into workflow-focused modules.
|
|
6
6
|
*
|
|
7
|
-
* sync is a standalone skill
|
|
8
|
-
* whether a sync is warranted and
|
|
9
|
-
*
|
|
7
|
+
* sync is a standalone skill, and also archive's automatic first step: archive
|
|
8
|
+
* decides whether a sync is warranted and, when it is, runs this procedure
|
|
9
|
+
* without asking. Step 4's judge-before-write gate is what makes running it
|
|
10
|
+
* unannounced safe.
|
|
10
11
|
*/
|
|
11
12
|
import type { SkillTemplate, CommandTemplate } from '../types.js';
|
|
12
13
|
export declare function getTospecSyncSkillTemplate(): SkillTemplate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/core/templates/workflows/sync.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/core/templates/workflows/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA8ElE,wBAAgB,0BAA0B,IAAI,aAAa,CAc1D;AAED,wBAAgB,4BAA4B,IAAI,eAAe,CAY9D"}
|
|
@@ -8,22 +8,36 @@ const SYNC_BODY = `Whether a spec still matches the source code is a semantic ju
|
|
|
8
8
|
|
|
9
9
|
**No-delta case**: an issue fix with no behavior change has no delta specs at all. Don't invent Requirements to check — instead confirm \`task.md\`'s described fix matches what the code actually does, and note this as the no-delta case in the report (see format below).
|
|
10
10
|
|
|
11
|
-
2. **
|
|
11
|
+
2. **Judge each Requirement against the actual implementation — writing nothing**
|
|
12
|
+
|
|
13
|
+
Steps 2 and 3 are the judge phase: they produce verdicts only. **Do not edit a spec file yet, however obviously stale it looks.** Record each verdict and move on; step 4 does all the writing, once every Requirement has a verdict.
|
|
12
14
|
|
|
13
15
|
For each Requirement, locate the corresponding code (the files apply touched are a good starting point) and judge: does the implemented behavior match what the Requirement's scenarios describe?
|
|
14
16
|
|
|
15
17
|
**Can't find any corresponding implementation at all**: that's a CODE-BUG, same severity as a behavioral mismatch — the Requirement was agreed to and never built. Don't wave it through as MATCH.
|
|
16
18
|
|
|
17
|
-
3. **
|
|
19
|
+
3. **Sweep the other direction — behavior nobody asked for**
|
|
20
|
+
|
|
21
|
+
Step 2 walks Requirements to code, so it can only find what is *missing*. It cannot see the opposite: behavior in the diff that **maps to no Requirement** at all. Walk the change's diff once and flag anything the specs never asked for.
|
|
22
|
+
|
|
23
|
+
**Report it, never spec it.** "Code wins" settles how a Requirement is *worded*, not whether behavior *belongs* — it is not a licence to make unrequested work look agreed after the fact. Never add a Requirement to cover scope creep: tell the user what you found and let them decide to keep it, drop it, or plan it properly.
|
|
24
|
+
|
|
25
|
+
4. **Write the resolutions — code wins**
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
Start this phase **only once steps 2 and 3 are complete and no Requirement is a CODE-BUG.** That gate is what makes it safe for \`tospec-archive\` to run this workflow without announcing it: because every defect surfaces while the judge phase is still writing nothing, walking away at this point leaves every spec file unmodified.
|
|
28
|
+
|
|
29
|
+
- **Any CODE-BUG** (the code doesn't do what was agreed in ticket/design, or was never built): **stop before writing anything.** Do not touch the spec to paper over a bug, and do not write the SPEC-UPDATED entries you already judged — they keep until the defect is resolved. Report the mismatch and go to step 5 with \`Conclusion: FAIL\`.
|
|
30
|
+
|
|
31
|
+
**Resuming after the defect is fixed** (this is how \`tospec-archive\` re-enters on its "fix now" branch): come back to *this step*, not to step 1. Re-judge only the Requirements that were CODE-BUG; every other verdict still stands. Once none of them is a defect any more, fall through to the bullet below and write **every** SPEC-UPDATED verdict — the ones held back here included, or their staleness ships into \`tospec/specs/\` on archive. Then rewrite \`sync-report.md\` (step 5) with the new conclusion; a report left at FAIL blocks the archive gate.
|
|
32
|
+
- **No CODE-BUG**: work the SPEC-UPDATED verdicts one at a time. For each, update the delta spec's Requirement with **MODIFIED**, pasting the complete, corrected Requirement block. Then:
|
|
20
33
|
\`\`\`bash
|
|
21
34
|
tospec validate "<name>" --json
|
|
22
35
|
\`\`\`
|
|
23
|
-
Must pass before
|
|
24
|
-
- If the code itself is wrong (it doesn't do what was actually agreed in ticket/design, or is missing entirely): **stop**. Do not touch the spec to paper over a bug. Report the mismatch to the user and suggest returning to \`tospec-apply\` to fix the code before archiving.
|
|
36
|
+
Must pass before writing the next one — one write, one validate, so a failure names the Requirement that caused it instead of leaving you to bisect a bulk edit. Record the validate result in that Requirement's report entry.
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
**If that validate fails**, the MODIFIED block you just wrote is malformed — an artifact problem, not a code defect. Fix that block and re-run \`tospec validate\` until it passes, then carry on with the remaining verdicts. Only if you cannot make it pass do you stop and report \`Conclusion: FAIL\`, naming the Requirement; that FAIL is not a CODE-BUG and archive handles it as an artifact fix, not a return to \`tospec-apply\`.
|
|
39
|
+
|
|
40
|
+
5. **Write the sync report**
|
|
27
41
|
|
|
28
42
|
Create \`sync-report.md\` in the change directory in exactly this format — \`tospec archive --require-sync\` parses the first \`Conclusion:\` line, so the heading and label text must match:
|
|
29
43
|
|
|
@@ -40,7 +54,7 @@ const SYNC_BODY = `Whether a spec still matches the source code is a semantic ju
|
|
|
40
54
|
|
|
41
55
|
Fill the \`Conclusion:\` line with exactly one literal — \`Conclusion: PASS\` or \`Conclusion: FAIL\` (FAIL may append a \`(reason)\` note); never leave both options in one line, or \`tospec archive --require-sync\` can't parse it. \`Conclusion:\` is **FAIL** if even one Requirement is CODE-BUG — a single unresolved defect blocks the whole change, not just that Requirement. It's **PASS** only when every Requirement resolved to MATCH or SPEC-UPDATED (with validate passing). For the no-delta case, still emit the Summary and a single Requirements entry describing the task.md-vs-code comparison (module described, not a Requirement name).
|
|
42
56
|
|
|
43
|
-
|
|
57
|
+
6. **Final artifact validation**
|
|
44
58
|
\`\`\`bash
|
|
45
59
|
tospec validate "<name>" --json
|
|
46
60
|
\`\`\`
|
|
@@ -48,19 +62,22 @@ const SYNC_BODY = `Whether a spec still matches the source code is a semantic ju
|
|
|
48
62
|
|
|
49
63
|
**Output**
|
|
50
64
|
|
|
51
|
-
Summarize how many Requirements
|
|
65
|
+
Summarize how many Requirements matched, how many specs were updated, whether anything was flagged as a code defect, and anything found that no Requirement asked for.
|
|
66
|
+
|
|
67
|
+
Where that summary goes depends on who called you. **Run from \`tospec-archive\`** (the usual case): hand the summary straight back — archive continues on \`Conclusion: PASS\`, passing \`--require-sync\` for free, and on \`Conclusion: FAIL\` archive owns the single question about fixing the defect. Do not prompt for archiving yourself; you are already inside it. **Run standalone**: on \`Conclusion: PASS\` prompt "Run \`tospec-archive\` to finish up", and on \`Conclusion: FAIL\` prompt to return to \`tospec-apply\` first.
|
|
52
68
|
|
|
53
69
|
**Guardrails**
|
|
54
70
|
- Code is the source of truth for behavior — spec updates always follow code, never the other way around
|
|
71
|
+
- Scope creep is reported, never specced — "code wins" settles a Requirement's wording, never whether unrequested behavior belongs
|
|
55
72
|
- Never edit source code from this workflow — a code-side mismatch is diagnosis, not a license to patch here
|
|
56
|
-
-
|
|
73
|
+
- Judge every Requirement before writing any spec update; inside the write phase, every MODIFIED delta must re-pass \`tospec validate\` before writing the next one
|
|
57
74
|
- \`sync-report.md\` is required output, in the exact format above — \`tospec archive --require-sync\` depends on both its existence and its \`Conclusion:\` line
|
|
58
75
|
- One comparison pass per Requirement — check it against the code once and record the verdict. \`sync-report.md\` is the deliverable, not another review target: don't re-audit the report after writing it, and don't re-check a Requirement already judged MATCH`;
|
|
59
76
|
export function getTospecSyncSkillTemplate() {
|
|
60
77
|
return {
|
|
61
78
|
name: 'tospec-sync',
|
|
62
|
-
description: '
|
|
63
|
-
instructions: `
|
|
79
|
+
description: 'Sync a change\'s Requirements against the actual implementation — code wins on any mismatch — and write sync-report.md. Use before archiving a change whose specs may have drifted from the code.',
|
|
80
|
+
instructions: `Sync \`specs/\` against the implementation for every Requirement this change touched — code wins on any mismatch. Run this before \`tospec-archive\` when the change's specs may have drifted from the code.
|
|
64
81
|
|
|
65
82
|
**Input**: The user's request should name the change to sync.
|
|
66
83
|
|
|
@@ -74,10 +91,10 @@ ${SYNC_BODY}`,
|
|
|
74
91
|
export function getTospecSyncCommandTemplate() {
|
|
75
92
|
return {
|
|
76
93
|
name: 'TOSPEC: Sync',
|
|
77
|
-
description: '
|
|
94
|
+
description: 'Sync specs against the implementation, code as source of truth',
|
|
78
95
|
category: 'Workflow',
|
|
79
96
|
tags: ['workflow', 'sync', 'archive-gate'],
|
|
80
|
-
content: `
|
|
97
|
+
content: `Sync \`specs/\` against the implementation for every Requirement this change touched — code wins on any mismatch. Run this before \`tospec-archive\` when the change's specs may have drifted from the code.
|
|
81
98
|
|
|
82
99
|
**Input**: The argument after \`tospec-sync\` is the change name to sync.
|
|
83
100
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../src/core/templates/workflows/sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../src/core/templates/workflows/sync.ts"],"names":[],"mappings":"AAaA,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mQA0EiP,CAAC;AAEpQ,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,mMAAmM;QAChN,YAAY,EAAE;;;;EAIhB,SAAS,EAAE;QACT,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,sBAAsB;QACrC,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC9B,YAAY,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,gEAAgE;QAC7E,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,CAAC;QAC1C,OAAO,EAAE;;;;EAIX,SAAS,EAAE;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -17,7 +17,7 @@ const UPDATE_BODY = `**Steps**
|
|
|
17
17
|
|
|
18
18
|
The artifact ids and paths come from the active schema — never assume them, and never branch on hardcoded artifact names. Custom schemas must work unchanged.
|
|
19
19
|
|
|
20
|
-
The files to edit are \`artifactPaths.<id>.existingOutputPaths\` — the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. \`specs
|
|
20
|
+
The files to edit are \`artifactPaths.<id>.existingOutputPaths\` — the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. \`specs/*/spec.md\`). Do NOT write to \`resolvedOutputPath\`: for a glob artifact it is still the glob pattern, not a real file.
|
|
21
21
|
|
|
22
22
|
3. **Understand the request**
|
|
23
23
|
- If the user asked for a specific revision ("the design now uses X"), that is the starting edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/core/update.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/core/update.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,OAAO,GAAE,oBAAyB;IAIxC,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoKjD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAkBtB;;;OAGG;IACH,OAAO,CAAC,+BAA+B;IAkBvC;;;;OAIG;YACW,yBAAyB;CA0BxC"}
|
package/dist/core/update.js
CHANGED
|
@@ -10,6 +10,7 @@ import { FileSystemUtils } from '../utils/file-system.js';
|
|
|
10
10
|
import { AI_TOOLS, TOSPEC_DIR_NAME } from './config.js';
|
|
11
11
|
import { getToolVersionStatus, getSkillTemplates, writeSkillDir, getConfiguredTools, removeLegacySkillDirs, removeLegacyToolSkillLayout, writeToolCommands, } from './shared/index.js';
|
|
12
12
|
import { getGlobalConfig } from './global-config.js';
|
|
13
|
+
import { runLegacyUserStateMigration } from './user-state-migration.js';
|
|
13
14
|
import { getProfileWorkflows, ALL_WORKFLOWS } from './profiles.js';
|
|
14
15
|
import { getAvailableTools } from './available-tools.js';
|
|
15
16
|
import { copyDir } from '../utils/link.js';
|
|
@@ -17,15 +18,15 @@ const require = createRequire(import.meta.url);
|
|
|
17
18
|
const { version: TOSPEC_VERSION } = require('../../package.json');
|
|
18
19
|
const OLD_CORE_WORKFLOWS = ['propose', 'explore', 'apply', 'archive'];
|
|
19
20
|
const WORKFLOW_TO_SKILL_DIR = Object.fromEntries(getSkillTemplates().map(({ workflowId, dirName }) => [workflowId, dirName]));
|
|
20
|
-
function getConfiguredProjectTools(projectPath) {
|
|
21
|
-
return getConfiguredTools(projectPath);
|
|
22
|
-
}
|
|
23
21
|
export class UpdateCommand {
|
|
24
22
|
force;
|
|
25
23
|
constructor(options = {}) {
|
|
26
24
|
this.force = options.force ?? false;
|
|
27
25
|
}
|
|
28
26
|
async execute(projectPath) {
|
|
27
|
+
// Above every getGlobalConfig() below, so this run reads the migrated file
|
|
28
|
+
// rather than the legacy fallback.
|
|
29
|
+
await runLegacyUserStateMigration();
|
|
29
30
|
const resolvedProjectPath = path.resolve(projectPath);
|
|
30
31
|
const tospecPath = path.join(resolvedProjectPath, TOSPEC_DIR_NAME);
|
|
31
32
|
// 1. Check tospec directory exists
|
|
@@ -38,7 +39,7 @@ export class UpdateCommand {
|
|
|
38
39
|
const profileWorkflows = getProfileWorkflows(profile, globalConfig.workflows);
|
|
39
40
|
const desiredWorkflows = profileWorkflows.filter((workflow) => ALL_WORKFLOWS.includes(workflow));
|
|
40
41
|
// 5. Find configured tools
|
|
41
|
-
const configuredTools =
|
|
42
|
+
const configuredTools = getConfiguredTools(resolvedProjectPath);
|
|
42
43
|
if (configuredTools.length === 0) {
|
|
43
44
|
console.log('No configured tools found.');
|
|
44
45
|
console.log('Run "tospec init" to set up tools.');
|
|
@@ -54,11 +55,7 @@ export class UpdateCommand {
|
|
|
54
55
|
const toolsNeedingVersionUpdate = toolStatuses
|
|
55
56
|
.filter((s) => s.needsUpdate)
|
|
56
57
|
.map((s) => s.toolId);
|
|
57
|
-
const
|
|
58
|
-
const toolsToUpdateSet = new Set([
|
|
59
|
-
...toolsNeedingVersionUpdate,
|
|
60
|
-
...toolsNeedingConfigSync,
|
|
61
|
-
]);
|
|
58
|
+
const toolsToUpdateSet = new Set(toolsNeedingVersionUpdate);
|
|
62
59
|
const toolsUpToDate = toolStatuses.filter((s) => !toolsToUpdateSet.has(s.toolId));
|
|
63
60
|
if (!this.force && toolsToUpdateSet.size === 0) {
|
|
64
61
|
// The generated version is current, but update is also the repair path
|
|
@@ -171,13 +168,11 @@ export class UpdateCommand {
|
|
|
171
168
|
* Display the update plan showing which tools need updating.
|
|
172
169
|
*/
|
|
173
170
|
displayUpdatePlan(toolsToUpdate, statusByTool, upToDate) {
|
|
171
|
+
// Every id in toolsToUpdate came from a status with needsUpdate === true,
|
|
172
|
+
// so there is no non-version reason to be in this list.
|
|
174
173
|
const updates = toolsToUpdate.map((toolId) => {
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const fromVersion = status.generatedByVersion ?? 'unknown';
|
|
178
|
-
return `${status.toolId} (${fromVersion} → ${TOSPEC_VERSION})`;
|
|
179
|
-
}
|
|
180
|
-
return `${toolId} (config sync)`;
|
|
174
|
+
const fromVersion = statusByTool.get(toolId)?.generatedByVersion ?? 'unknown';
|
|
175
|
+
return `${toolId} (${fromVersion} → ${TOSPEC_VERSION})`;
|
|
181
176
|
});
|
|
182
177
|
console.log(`Updating ${toolsToUpdate.length} tool(s): ${updates.join(', ')}`);
|
|
183
178
|
if (upToDate.length > 0) {
|