freeharness 0.4.1 → 0.4.2
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/README.md +8 -7
- package/canonical/HARVEST.yaml +25 -14
- package/canonical/PROVENANCE.yaml +1 -1
- package/canonical/agents/README.md +77 -36
- package/canonical/agents/agentic-architect.md +2 -1
- package/canonical/agents/database-reviewer.md +6 -8
- package/canonical/agents/explorer-ai-engineer-analyst.md +2 -6
- package/canonical/agents/implementer.md +30 -0
- package/canonical/agents/pr-reviewer.md +9 -11
- package/canonical/agents/python-reviewer.md +7 -9
- package/canonical/agents/report-formatter.md +7 -3
- package/canonical/agents/security-reviewer.md +7 -8
- package/canonical/agents/test-writer.md +5 -2
- package/canonical/hooks/cost-prices.json +11 -9
- package/canonical/hooks/freeharness-config-guard.mjs +8072 -87
- package/canonical/hooks/freeharness-context-monitor.mjs +88 -54
- package/canonical/hooks/freeharness-converge.mjs +78 -23
- package/canonical/hooks/freeharness-cost-tracker.mjs +1129 -218
- package/canonical/hooks/freeharness-memory-guard.mjs +20 -23
- package/canonical/hooks/freeharness-precompact.mjs +217 -87
- package/canonical/hooks/freeharness-quota-tap.mjs +173 -0
- package/canonical/hooks/freeharness-reload-context.mjs +197 -0
- package/canonical/hooks/freeharness-repeat-tool.mjs +1 -1
- package/canonical/hooks/freeharness-sdd-context.mjs +970 -0
- package/canonical/hooks/freeharness-session-start +297 -59
- package/canonical/hooks/hooks.claude-code.json +1 -1
- package/canonical/hooks/hooks.config-guard.claude-code.json +3 -2
- package/canonical/hooks/hooks.context-monitor.claude-code.json +1 -1
- package/canonical/hooks/hooks.converge.claude-code.json +1 -1
- package/canonical/hooks/hooks.memory-guard.claude-code.json +3 -2
- package/canonical/hooks/hooks.reload-context.claude-code.json +15 -0
- package/canonical/openspec/schema.spec-driven.yaml +29 -8
- package/canonical/openspec/templates/follow-ups.md +3 -2
- package/canonical/openspec/templates/proposal.md +1 -1
- package/canonical/openspec/templates/tasks.md +8 -0
- package/canonical/rules/CLAUDE.md +5 -4
- package/canonical/rules/routing.md +10 -9
- package/canonical/skills/agent-evaluation/SKILL.md +17 -6
- package/canonical/skills/agent-evaluation/evals/cases.yaml +38 -23
- package/canonical/skills/agentic-architecture/SKILL.md +4 -0
- package/canonical/skills/agentic-architecture/evals/cases.yaml +27 -0
- package/canonical/skills/code-review/SKILL.md +9 -2
- package/canonical/skills/code-review/evals/cases.yaml +1118 -27
- package/canonical/skills/git-workflow/SKILL.md +2 -0
- package/canonical/skills/local-code/SKILL.md +2 -2
- package/canonical/skills/local-code/evals/cases.yaml +1 -1
- package/canonical/skills/report-formatting/SKILL.md +10 -2
- package/canonical/skills/report-formatting/reference/ARCHITECTURE.md +3 -3
- package/canonical/skills/report-formatting/reference/HELPERS.md +10 -5
- package/canonical/skills/report-formatting/reference/RELEASE.md +1 -2
- package/canonical/skills/report-formatting/reference/TEMPLATES.md +3 -2
- package/canonical/skills/report-formatting/reference/authoring.md +25 -37
- package/canonical/skills/report-formatting/scripts/build-architecture.js +1 -1
- package/canonical/skills/report-formatting/scripts/build-md-claro.js +5 -8
- package/canonical/skills/report-formatting/scripts/check-env.js +0 -4
- package/canonical/skills/report-formatting/scripts/docmodel.js +3 -11
- package/canonical/skills/report-formatting/scripts/example-build.js +8 -10
- package/canonical/skills/report-formatting/scripts/example_build_ArchitectureReview_docx.js +8 -10
- package/canonical/skills/report-formatting/scripts/example_build_ExecutiveReport_docx.js +8 -10
- package/canonical/skills/report-formatting/scripts/theme-claro.js +39 -10
- package/canonical/skills/subagent-driven-development/SKILL.md +35 -28
- package/canonical/skills/subagent-driven-development/evals/cases.yaml +3496 -19
- package/canonical/skills/subagent-driven-development/reference/brief.md +185 -35
- package/canonical/skills/subagent-driven-development/reference/handoff.md +82 -2
- package/canonical/skills/subagent-driven-development/reference/loop.md +57 -0
- package/canonical/skills/subagent-driven-development/reference/trees.md +40 -0
- package/canonical/skills/subagent-driven-development/reference/workspace.md +31 -0
- package/canonical/skills/subagent-driven-development/scripts/validate-handoff.mjs +4771 -326
- package/dist/adapters/harness/claude-code.d.ts +19 -3
- package/dist/adapters/harness/claude-code.js +204 -39
- package/dist/adapters/harness/opencode.js +16 -2
- package/dist/adapters/harness/plugin.js +28 -17
- package/dist/adapters/memory/doctor.d.ts +174 -29
- package/dist/adapters/memory/doctor.js +758 -134
- package/dist/adapters/memory/migrate.d.ts +95 -0
- package/dist/adapters/memory/migrate.js +497 -0
- package/dist/adapters/memory/paths.d.ts +22 -0
- package/dist/adapters/memory/paths.js +85 -0
- package/dist/adapters/memory/vendored.d.ts +56 -29
- package/dist/adapters/memory/vendored.js +191 -154
- package/dist/adapters/sync/diff.js +4 -1
- package/dist/cli/cleanup-prompt.d.ts +35 -0
- package/dist/cli/cleanup-prompt.js +68 -0
- package/dist/cli/cleanup.d.ts +22 -24
- package/dist/cli/cleanup.js +182 -68
- package/dist/cli/cost-quota.d.ts +158 -0
- package/dist/cli/cost-quota.js +645 -0
- package/dist/cli/cost.d.ts +408 -46
- package/dist/cli/cost.js +1731 -57
- package/dist/cli/doctor.d.ts +52 -13
- package/dist/cli/doctor.js +193 -44
- package/dist/cli/hard-cleanup.d.ts +93 -0
- package/dist/cli/hard-cleanup.js +552 -0
- package/dist/cli/install-facts.d.ts +28 -0
- package/dist/cli/install-facts.js +66 -0
- package/dist/cli/json-key-edit.d.ts +18 -0
- package/dist/cli/json-key-edit.js +118 -0
- package/dist/cli/memory-import.d.ts +74 -0
- package/dist/cli/memory-import.js +469 -0
- package/dist/cli/plugin-validate.d.ts +12 -0
- package/dist/cli/plugin-validate.js +43 -0
- package/dist/cli/uninstall.d.ts +1 -1
- package/dist/cli/uninstall.js +2 -2
- package/dist/cli/upstream-launchers.d.ts +49 -0
- package/dist/cli/upstream-launchers.js +287 -0
- package/dist/index.js +247 -70
- package/dist/infra/fsutil.d.ts +31 -3
- package/dist/infra/fsutil.js +69 -6
- package/dist/infra/manifest.d.ts +2 -1
- package/dist/infra/manifest.js +3 -2
- package/dist/infra/prices.d.ts +18 -0
- package/dist/infra/prices.js +64 -0
- package/node_modules/@freeharness/core/dist/tiers.d.ts +10 -1
- package/node_modules/@freeharness/core/dist/tiers.js +24 -2
- package/node_modules/@freeharness/core/package.json +1 -1
- package/node_modules/@freeharness/sdd/PROVENANCE.yaml +279 -2
- package/node_modules/@freeharness/sdd/dist/src/bin/openspec.js +34 -8
- package/node_modules/@freeharness/sdd/dist/src/shim/archive.d.ts +7 -6
- package/node_modules/@freeharness/sdd/dist/src/shim/archive.js +72 -64
- package/node_modules/@freeharness/sdd/dist/src/shim/follow-up.d.ts +48 -16
- package/node_modules/@freeharness/sdd/dist/src/shim/follow-up.js +168 -70
- package/node_modules/@freeharness/sdd/dist/src/shim/instructions.d.ts +36 -6
- package/node_modules/@freeharness/sdd/dist/src/shim/instructions.js +110 -49
- package/node_modules/@freeharness/sdd/dist/src/shim/list.d.ts +1 -1
- package/node_modules/@freeharness/sdd/dist/src/shim/list.js +57 -14
- package/node_modules/@freeharness/sdd/dist/src/shim/nested-change.d.ts +7 -0
- package/node_modules/@freeharness/sdd/dist/src/shim/nested-change.js +118 -0
- package/node_modules/@freeharness/sdd/dist/src/shim/new-change.js +3 -1
- package/node_modules/@freeharness/sdd/dist/src/shim/proposal-capabilities.d.ts +12 -0
- package/node_modules/@freeharness/sdd/dist/src/shim/proposal-capabilities.js +94 -0
- package/node_modules/@freeharness/sdd/dist/src/shim/shared.d.ts +17 -0
- package/node_modules/@freeharness/sdd/dist/src/shim/shared.js +182 -1
- package/node_modules/@freeharness/sdd/dist/src/shim/status.d.ts +2 -2
- package/node_modules/@freeharness/sdd/dist/src/shim/status.js +34 -5
- package/node_modules/@freeharness/sdd/dist/src/shim/validate.d.ts +9 -0
- package/node_modules/@freeharness/sdd/dist/src/shim/validate.js +49 -41
- package/node_modules/@freeharness/sdd/dist/src/shim/warnings.d.ts +21 -0
- package/node_modules/@freeharness/sdd/dist/src/shim/warnings.js +66 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/apply/line-endings.d.ts +4 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/apply/line-endings.js +17 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/apply/specs-apply.js +95 -22
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/engine/change-status-policy.d.ts +6 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/engine/change-status-policy.js +14 -6
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/engine/index.d.ts +1 -1
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/engine/index.js +1 -1
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/engine/outputs.d.ts +3 -3
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/engine/outputs.js +24 -4
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/engine/task-progress.js +4 -7
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/engine/types.js +13 -1
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/generation/templates/workflows/apply-change.js +21 -6
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/generation/templates/workflows/archive-change.js +80 -19
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/generation/templates/workflows/explore.js +42 -22
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/generation/templates/workflows/project-root.d.ts +32 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/generation/templates/workflows/project-root.js +39 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/generation/templates/workflows/propose.js +16 -9
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/generation/templates/workflows/sync-specs.js +36 -1
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/generation/templates/workflows/update-change.js +65 -30
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/constants.d.ts +1 -1
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/constants.js +1 -1
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/change-parser.d.ts +8 -13
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/change-parser.js +79 -102
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/markdown-parser.js +4 -9
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/requirement-blocks.d.ts +50 -10
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/requirement-blocks.js +165 -37
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/requirement-text.d.ts +24 -3
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/requirement-text.js +55 -8
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/spec-structure.js +4 -1
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/purpose-placeholder.js +19 -9
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/spec-discovery.d.ts +10 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/spec-discovery.js +115 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/task-lines.d.ts +3 -3
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/task-lines.js +20 -20
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/validator.d.ts +6 -0
- package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/validator.js +75 -14
- package/node_modules/@freeharness/sdd/package.json +1 -1
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/schema.upstream.yaml +47 -7
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-apply-change/SKILL.md +25 -7
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-archive-change/SKILL.md +50 -11
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-bulk-archive-change/SKILL.md +48 -10
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-continue-change/SKILL.md +27 -7
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-explore/SKILL.md +25 -12
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-ff-change/SKILL.md +17 -5
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-new-change/SKILL.md +12 -1
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-onboard/SKILL.md +47 -33
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-propose/SKILL.md +17 -5
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-sync-specs/SKILL.md +29 -1
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-update-change/SKILL.md +31 -13
- package/node_modules/@freeharness/sdd/vendor/openspec/assets/skills/openspec-verify-change/SKILL.md +75 -27
- package/package.json +6 -4
- package/provenance/canonical.PROVENANCE.yaml +1 -1
- package/provenance/memory.PROVENANCE.yaml +458 -6
- package/provenance/sdd.PROVENANCE.yaml +279 -2
- package/canonical/hooks/freeharness-auto-memory.mjs +0 -158
- package/canonical/hooks/hooks.auto-memory.claude-code.json +0 -16
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { STORE_SELECTION_GUIDANCE } from './store-selection.js';
|
|
2
|
+
import { PROJECT_ROOT_GUARD } from './project-root.js';
|
|
2
3
|
export function getSyncSpecsSkillTemplate() {
|
|
3
4
|
return {
|
|
4
5
|
name: 'openspec-sync-specs',
|
|
5
|
-
description: 'Sync delta specs from
|
|
6
|
+
description: 'Sync delta specs from an OpenSpec change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.',
|
|
6
7
|
instructions: `Sync delta specs from a change to main specs.
|
|
7
8
|
|
|
8
9
|
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
|
|
9
10
|
|
|
10
11
|
${STORE_SELECTION_GUIDANCE}
|
|
11
12
|
|
|
13
|
+
${PROJECT_ROOT_GUARD}
|
|
14
|
+
|
|
12
15
|
\`<capability-path>\` is the spec directory relative to \`specs/\` (for example, \`user-auth\` or \`identity/user-auth\`). Preserve the full path from each delta spec when resolving its main spec.
|
|
13
16
|
|
|
14
17
|
**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.
|
|
@@ -89,6 +92,13 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
89
92
|
|
|
90
93
|
b. **Read the main spec** at \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\` (may not exist yet)
|
|
91
94
|
|
|
95
|
+
**If it does not exist yet** (a new capability), match what \`openspec archive\` does:
|
|
96
|
+
only ADDED requirements may be applied - step d creates the spec from them.
|
|
97
|
+
MODIFIED and RENAMED have no requirement to act on, so stop the sync for that
|
|
98
|
+
capability and report that its main spec does not exist and only ADDED is allowed
|
|
99
|
+
for a new spec; never invent the missing requirement. REMOVED has nothing to
|
|
100
|
+
remove - skip it and warn.
|
|
101
|
+
|
|
92
102
|
c. **Apply changes intelligently**:
|
|
93
103
|
|
|
94
104
|
**ADDED Requirements:**
|
|
@@ -136,6 +146,14 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
136
146
|
(this is what \`openspec archive\` does; it warns and moves on)
|
|
137
147
|
|
|
138
148
|
d. **Create new main spec** if capability doesn't exist yet:
|
|
149
|
+
- Only when the delta has ADDED requirements to put in it and no MODIFIED or
|
|
150
|
+
RENAMED requirements blocked this capability in step b. Otherwise create nothing
|
|
151
|
+
and leave the specs directory untouched. For a REMOVED-only delta, if the change's
|
|
152
|
+
\`.openspec.yaml\` declares \`retire_capabilities: true\`, report it as already retired
|
|
153
|
+
and continue without recreating the spec. Without that marker, report the sync as blocked:
|
|
154
|
+
\`openspec archive\` rejects it with \`Spec must have at least one requirement\`.
|
|
155
|
+
An empty delta has no operations to sync; report it as blocked too.
|
|
156
|
+
Never write an empty \`## Requirements\` section.
|
|
139
157
|
- Create \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\`
|
|
140
158
|
- Add Purpose section: copy the delta's \`## Purpose\` body verbatim when it has one
|
|
141
159
|
(this is what \`openspec archive\` does); only write a brief TBD placeholder when it does not
|
|
@@ -270,6 +288,8 @@ This is an **agent-driven** operation - you will read delta specs and directly e
|
|
|
270
288
|
|
|
271
289
|
${STORE_SELECTION_GUIDANCE}
|
|
272
290
|
|
|
291
|
+
${PROJECT_ROOT_GUARD}
|
|
292
|
+
|
|
273
293
|
\`<capability-path>\` is the spec directory relative to \`specs/\` (for example, \`user-auth\` or \`identity/user-auth\`). Preserve the full path from each delta spec when resolving its main spec.
|
|
274
294
|
|
|
275
295
|
**Input**: Optionally specify a change name after \`/opsx:sync\` (e.g., \`/opsx:sync add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
@@ -350,6 +370,13 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
350
370
|
|
|
351
371
|
b. **Read the main spec** at \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\` (may not exist yet)
|
|
352
372
|
|
|
373
|
+
**If it does not exist yet** (a new capability), match what \`openspec archive\` does:
|
|
374
|
+
only ADDED requirements may be applied - step d creates the spec from them.
|
|
375
|
+
MODIFIED and RENAMED have no requirement to act on, so stop the sync for that
|
|
376
|
+
capability and report that its main spec does not exist and only ADDED is allowed
|
|
377
|
+
for a new spec; never invent the missing requirement. REMOVED has nothing to
|
|
378
|
+
remove - skip it and warn.
|
|
379
|
+
|
|
353
380
|
c. **Apply changes intelligently**:
|
|
354
381
|
|
|
355
382
|
**ADDED Requirements:**
|
|
@@ -397,6 +424,14 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
397
424
|
(this is what \`openspec archive\` does; it warns and moves on)
|
|
398
425
|
|
|
399
426
|
d. **Create new main spec** if capability doesn't exist yet:
|
|
427
|
+
- Only when the delta has ADDED requirements to put in it and no MODIFIED or
|
|
428
|
+
RENAMED requirements blocked this capability in step b. Otherwise create nothing
|
|
429
|
+
and leave the specs directory untouched. For a REMOVED-only delta, if the change's
|
|
430
|
+
\`.openspec.yaml\` declares \`retire_capabilities: true\`, report it as already retired
|
|
431
|
+
and continue without recreating the spec. Without that marker, report the sync as blocked:
|
|
432
|
+
\`openspec archive\` rejects it with \`Spec must have at least one requirement\`.
|
|
433
|
+
An empty delta has no operations to sync; report it as blocked too.
|
|
434
|
+
Never write an empty \`## Requirements\` section.
|
|
400
435
|
- Create \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\`
|
|
401
436
|
- Add Purpose section: copy the delta's \`## Purpose\` body verbatim when it has one
|
|
402
437
|
(this is what \`openspec archive\` does); only write a brief TBD placeholder when it does not
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { STORE_SELECTION_GUIDANCE } from './store-selection.js';
|
|
2
|
+
import { PROJECT_ROOT_GUARD } from './project-root.js';
|
|
3
|
+
/**
|
|
4
|
+
* Passages that would hand off to \`/opsx:continue\` or \`/opsx:new\`. Neither
|
|
5
|
+
* workflow is among FreeHarness's six emitted workflows, so each always
|
|
6
|
+
* renders the CLI fallback rather than naming a skill that was never
|
|
7
|
+
* generated.
|
|
8
|
+
*/
|
|
9
|
+
const CONTINUE_SCOPE_NOTE = 'This workflow revises artifacts that already exist; it never creates missing ones. When an artifact is missing, `openspec status --change "<name>" --json` names the next one and `openspec instructions "<artifact-id>" --change "<name>" --json` explains how to write it.';
|
|
10
|
+
const CONTINUE_CREATE_THEM = 'point the user to `openspec instructions "<artifact-id>" --change "<name>" --json` for how to create them';
|
|
11
|
+
const CONTINUE_NEXT_STEP = 'run `openspec status --change "<name>" --json` for the next artifact and point the user to `openspec instructions "<artifact-id>" --change "<name>" --json` for how to create it';
|
|
12
|
+
const CONTINUE_DEFERRED = 'Anything deferred because it does not exist yet (artifacts with no files and status `ready` or `blocked`, never `skipped` artifacts)';
|
|
13
|
+
const CONTINUE_FRONTIER = 'creating them is a separate step, outside this workflow';
|
|
14
|
+
const INTENT_CHANGE_GUARDRAIL = 'ask for a distinct unused change name and recommend `openspec new change "<new-change-name>"` instead (the "Update vs. Start Fresh" heuristic)';
|
|
15
|
+
/** \`apply\` and \`archive\` are both shipped, so their handoffs always name the slash command. */
|
|
16
|
+
const APPLY_DELTA_HANDOFF = 'suggest `/opsx:apply` to carry the delta into code';
|
|
17
|
+
const APPLY_GUARDRAIL = 'stop and point to `/opsx:apply`';
|
|
18
|
+
const ARCHIVE_HANDOFF = 'suggest `/opsx:archive`';
|
|
2
19
|
export function getUpdateChangeSkillTemplate() {
|
|
3
20
|
return {
|
|
4
21
|
name: 'openspec-update-change',
|
|
@@ -7,9 +24,11 @@ export function getUpdateChangeSkillTemplate() {
|
|
|
7
24
|
|
|
8
25
|
${STORE_SELECTION_GUIDANCE}
|
|
9
26
|
|
|
27
|
+
${PROJECT_ROOT_GUARD}
|
|
28
|
+
|
|
10
29
|
**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.
|
|
11
30
|
|
|
12
|
-
|
|
31
|
+
${CONTINUE_SCOPE_NOTE}
|
|
13
32
|
|
|
14
33
|
**Steps**
|
|
15
34
|
|
|
@@ -22,7 +41,6 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
22
41
|
|
|
23
42
|
When prompting, present the top 3-4 most recently modified changes as options, showing:
|
|
24
43
|
- Change name
|
|
25
|
-
- Schema (from \`schema\` field if present, otherwise "spec-driven")
|
|
26
44
|
- Status (e.g., "0/5 tasks", "complete", "no tasks")
|
|
27
45
|
- How recently it was modified (from \`lastModified\` field)
|
|
28
46
|
|
|
@@ -42,7 +60,7 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
42
60
|
|
|
43
61
|
The artifact ids and paths come from the active schema - do NOT assume them, and do NOT branch on hardcoded artifact names. Custom schemas must work unchanged.
|
|
44
62
|
|
|
45
|
-
The files to edit are \`artifactPaths.<id>.existingOutputPaths\` - the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. \`specs/**/*.md\`). Do NOT write to \`resolvedOutputPath\`: for a glob artifact it is still the glob pattern, not a real file.
|
|
63
|
+
The files to edit are \`artifactPaths.<id>.existingOutputPaths\` - the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. \`specs/**/*.md\`), plus any confirmed concrete path allowed under a partly populated glob artifact (step 4). Do NOT write to \`resolvedOutputPath\`: for a glob artifact it is still the glob pattern, not a real file.
|
|
46
64
|
|
|
47
65
|
3. **Understand the request**
|
|
48
66
|
- If the user asked for a specific revision ("the design now uses X"), that is the starting edit.
|
|
@@ -50,13 +68,20 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
50
68
|
|
|
51
69
|
4. **Read and reconcile**
|
|
52
70
|
- Read the artifact(s) the request touches and the change's other existing artifacts.
|
|
53
|
-
-
|
|
71
|
+
- Draft the requested edit in the conversation, not in files. Work out exactly what it changes; step 5 owns every write. Then check every other existing artifact against the drafted edit - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
|
|
54
72
|
- Note everything that is now inconsistent, missing, or contradictory.
|
|
55
|
-
-
|
|
56
|
-
-
|
|
73
|
+
- Propose revisions to files that already exist (\`existingOutputPaths\`). If an artifact has no existing output files and status \`ready\` or \`blocked\`, note it and ${CONTINUE_CREATE_THEM}. Leave \`skipped\` artifacts untouched; do not treat them as missing or defer them to the continue workflow.
|
|
74
|
+
- A glob artifact (e.g. \`specs/**/*.md\`) is marked \`done\` after at least one file matches, and the continue workflow only handles \`ready\` artifacts. When reconciliation identifies a missing file for a glob artifact whose \`existingOutputPaths\` is non-empty:
|
|
75
|
+
1. Run \`openspec instructions "<artifact-id>" --change "<name>" --json\` and use its \`instruction\` and \`template\`. Treat \`context\` and \`rules\` as constraints; do not copy them into the file. If instructions report \`skipped: true\`, do not create the file. Read current dependency files from disk; if a required non-skipped dependency is missing, stop and ask the user to restore it first.
|
|
76
|
+
2. Choose a concrete path inside \`changeRoot\` that matches \`artifactPaths.<id>.outputPath\` and does not already exist. Verify it remains inside \`changeRoot\` after resolving any symlinked parent directories. The glob \`resolvedOutputPath\` is not a valid target.
|
|
77
|
+
3. Include the new file in step 5's proposed revisions and create it only after the user confirms.
|
|
78
|
+
4. After confirmation, immediately before creation, refresh status and instructions. Verify the artifact is still in scope, not skipped, and partially populated; repeat the concrete-path checks above.
|
|
79
|
+
5. Use a create operation that fails if the target already exists. If \`instruction\` delegates creation to another skill or command, invoke it only if it can honor the confirmed path and these guardrails; otherwise stop. If any check fails or the confirmed draft is no longer valid, stop and reconcile with the user rather than replacing existing content or choosing a different path.
|
|
80
|
+
- If the change is already coherent, say so and propose no revisions.
|
|
57
81
|
|
|
58
82
|
5. **Confirm and apply, one artifact at a time**
|
|
59
|
-
-
|
|
83
|
+
- This step performs every artifact write in this workflow; no earlier step edits an artifact.
|
|
84
|
+
- Show each proposed revision and why - including the requested edit drafted in step 4. Write only after the user confirms.
|
|
60
85
|
- If the user rejects a revision, do not write it - leave that artifact unchanged.
|
|
61
86
|
- When a substantial rewrite is needed, get that artifact's rules and template first:
|
|
62
87
|
\`\`\`bash
|
|
@@ -64,24 +89,25 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
64
89
|
\`\`\`
|
|
65
90
|
|
|
66
91
|
6. **Point to the next step (guidance only - NEVER act on it)**
|
|
67
|
-
- Artifacts
|
|
68
|
-
- Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan;
|
|
69
|
-
- Everything done and implemented ->
|
|
92
|
+
- Artifacts with empty \`existingOutputPaths\` and status \`ready\` or \`blocked\` -> ${CONTINUE_NEXT_STEP}.
|
|
93
|
+
- Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; ${APPLY_DELTA_HANDOFF}.
|
|
94
|
+
- Everything done and implemented -> ${ARCHIVE_HANDOFF}.
|
|
70
95
|
|
|
71
96
|
**Output**
|
|
72
97
|
|
|
73
98
|
After each invocation, show:
|
|
74
99
|
- Which artifacts were revised (and which proposed revisions were rejected)
|
|
75
|
-
-
|
|
100
|
+
- Any file created under a glob artifact that was already partially populated
|
|
101
|
+
- ${CONTINUE_DEFERRED}
|
|
76
102
|
- Where the change stands and the recommended next command
|
|
77
103
|
|
|
78
104
|
**Guardrails**
|
|
79
|
-
- Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes,
|
|
105
|
+
- Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, ${APPLY_GUARDRAIL}.
|
|
80
106
|
- Use the artifact ids and paths reported by \`openspec status\`; never branch on hardcoded artifact names.
|
|
81
|
-
- Edit only the concrete files in \`existingOutputPaths
|
|
82
|
-
- Do not advance the build frontier:
|
|
107
|
+
- Edit only the concrete files in \`existingOutputPaths\`, plus any confirmed concrete path allowed under a partly populated glob artifact (step 4); never write to a glob \`resolvedOutputPath\`.
|
|
108
|
+
- Do not advance the build frontier: if an artifact has empty \`existingOutputPaths\` and status \`ready\` or \`blocked\`, ${CONTINUE_FRONTIER}. Leave \`skipped\` artifacts untouched. The only new-file scope is a confirmed concrete path under a glob artifact whose \`existingOutputPaths\` is non-empty.
|
|
83
109
|
- Confirm every edit with the user before writing.
|
|
84
|
-
- If the request changes the change's *intent* rather than refining it,
|
|
110
|
+
- If the request changes the change's *intent* rather than refining it, ${INTENT_CHANGE_GUARDRAIL}.`,
|
|
85
111
|
license: 'MIT',
|
|
86
112
|
compatibility: 'Requires openspec CLI.',
|
|
87
113
|
metadata: { author: 'openspec', version: '1.0' },
|
|
@@ -97,9 +123,11 @@ export function getOpsxUpdateCommandTemplate() {
|
|
|
97
123
|
|
|
98
124
|
${STORE_SELECTION_GUIDANCE}
|
|
99
125
|
|
|
126
|
+
${PROJECT_ROOT_GUARD}
|
|
127
|
+
|
|
100
128
|
**Input**: Optionally specify a change name after \`/opsx:update\` (e.g., \`/opsx:update add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
101
129
|
|
|
102
|
-
|
|
130
|
+
${CONTINUE_SCOPE_NOTE}
|
|
103
131
|
|
|
104
132
|
**Steps**
|
|
105
133
|
|
|
@@ -112,7 +140,6 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
112
140
|
|
|
113
141
|
When prompting, present the top 3-4 most recently modified changes as options, showing:
|
|
114
142
|
- Change name
|
|
115
|
-
- Schema (from \`schema\` field if present, otherwise "spec-driven")
|
|
116
143
|
- Status (e.g., "0/5 tasks", "complete", "no tasks")
|
|
117
144
|
- How recently it was modified (from \`lastModified\` field)
|
|
118
145
|
|
|
@@ -132,7 +159,7 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
132
159
|
|
|
133
160
|
The artifact ids and paths come from the active schema - do NOT assume them, and do NOT branch on hardcoded artifact names. Custom schemas must work unchanged.
|
|
134
161
|
|
|
135
|
-
The files to edit are \`artifactPaths.<id>.existingOutputPaths\` - the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. \`specs/**/*.md\`). Do NOT write to \`resolvedOutputPath\`: for a glob artifact it is still the glob pattern, not a real file.
|
|
162
|
+
The files to edit are \`artifactPaths.<id>.existingOutputPaths\` - the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. \`specs/**/*.md\`), plus any confirmed concrete path allowed under a partly populated glob artifact (step 4). Do NOT write to \`resolvedOutputPath\`: for a glob artifact it is still the glob pattern, not a real file.
|
|
136
163
|
|
|
137
164
|
3. **Understand the request**
|
|
138
165
|
- If the user asked for a specific revision ("the design now uses X"), that is the starting edit.
|
|
@@ -140,13 +167,20 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
140
167
|
|
|
141
168
|
4. **Read and reconcile**
|
|
142
169
|
- Read the artifact(s) the request touches and the change's other existing artifacts.
|
|
143
|
-
-
|
|
170
|
+
- Draft the requested edit in the conversation, not in files. Work out exactly what it changes; step 5 owns every write. Then check every other existing artifact against the drafted edit - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
|
|
144
171
|
- Note everything that is now inconsistent, missing, or contradictory.
|
|
145
|
-
-
|
|
146
|
-
-
|
|
172
|
+
- Propose revisions to files that already exist (\`existingOutputPaths\`). If an artifact has no existing output files and status \`ready\` or \`blocked\`, note it and ${CONTINUE_CREATE_THEM}. Leave \`skipped\` artifacts untouched; do not treat them as missing or defer them to the continue workflow.
|
|
173
|
+
- A glob artifact (e.g. \`specs/**/*.md\`) is marked \`done\` after at least one file matches, and the continue workflow only handles \`ready\` artifacts. When reconciliation identifies a missing file for a glob artifact whose \`existingOutputPaths\` is non-empty:
|
|
174
|
+
1. Run \`openspec instructions "<artifact-id>" --change "<name>" --json\` and use its \`instruction\` and \`template\`. Treat \`context\` and \`rules\` as constraints; do not copy them into the file. If instructions report \`skipped: true\`, do not create the file. Read current dependency files from disk; if a required non-skipped dependency is missing, stop and ask the user to restore it first.
|
|
175
|
+
2. Choose a concrete path inside \`changeRoot\` that matches \`artifactPaths.<id>.outputPath\` and does not already exist. Verify it remains inside \`changeRoot\` after resolving any symlinked parent directories. The glob \`resolvedOutputPath\` is not a valid target.
|
|
176
|
+
3. Include the new file in step 5's proposed revisions and create it only after the user confirms.
|
|
177
|
+
4. After confirmation, immediately before creation, refresh status and instructions. Verify the artifact is still in scope, not skipped, and partially populated; repeat the concrete-path checks above.
|
|
178
|
+
5. Use a create operation that fails if the target already exists. If \`instruction\` delegates creation to another skill or command, invoke it only if it can honor the confirmed path and these guardrails; otherwise stop. If any check fails or the confirmed draft is no longer valid, stop and reconcile with the user rather than replacing existing content or choosing a different path.
|
|
179
|
+
- If the change is already coherent, say so and propose no revisions.
|
|
147
180
|
|
|
148
181
|
5. **Confirm and apply, one artifact at a time**
|
|
149
|
-
-
|
|
182
|
+
- This step performs every artifact write in this workflow; no earlier step edits an artifact.
|
|
183
|
+
- Show each proposed revision and why - including the requested edit drafted in step 4. Write only after the user confirms.
|
|
150
184
|
- If the user rejects a revision, do not write it - leave that artifact unchanged.
|
|
151
185
|
- When a substantial rewrite is needed, get that artifact's rules and template first:
|
|
152
186
|
\`\`\`bash
|
|
@@ -154,23 +188,24 @@ ${STORE_SELECTION_GUIDANCE}
|
|
|
154
188
|
\`\`\`
|
|
155
189
|
|
|
156
190
|
6. **Point to the next step (guidance only - NEVER act on it)**
|
|
157
|
-
- Artifacts
|
|
158
|
-
- Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan;
|
|
159
|
-
- Everything done and implemented ->
|
|
191
|
+
- Artifacts with empty \`existingOutputPaths\` and status \`ready\` or \`blocked\` -> ${CONTINUE_NEXT_STEP}.
|
|
192
|
+
- Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; ${APPLY_DELTA_HANDOFF}.
|
|
193
|
+
- Everything done and implemented -> ${ARCHIVE_HANDOFF}.
|
|
160
194
|
|
|
161
195
|
**Output**
|
|
162
196
|
|
|
163
197
|
After each invocation, show:
|
|
164
198
|
- Which artifacts were revised (and which proposed revisions were rejected)
|
|
165
|
-
-
|
|
199
|
+
- Any file created under a glob artifact that was already partially populated
|
|
200
|
+
- ${CONTINUE_DEFERRED}
|
|
166
201
|
- Where the change stands and the recommended next command
|
|
167
202
|
|
|
168
203
|
**Guardrails**
|
|
169
|
-
- Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes,
|
|
204
|
+
- Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, ${APPLY_GUARDRAIL}.
|
|
170
205
|
- Use the artifact ids and paths reported by \`openspec status\`; never branch on hardcoded artifact names.
|
|
171
|
-
- Edit only the concrete files in \`existingOutputPaths
|
|
172
|
-
- Do not advance the build frontier:
|
|
206
|
+
- Edit only the concrete files in \`existingOutputPaths\`, plus any confirmed concrete path allowed under a partly populated glob artifact (step 4); never write to a glob \`resolvedOutputPath\`.
|
|
207
|
+
- Do not advance the build frontier: if an artifact has empty \`existingOutputPaths\` and status \`ready\` or \`blocked\`, ${CONTINUE_FRONTIER}. Leave \`skipped\` artifacts untouched. The only new-file scope is a confirmed concrete path under a glob artifact whose \`existingOutputPaths\` is non-empty.
|
|
173
208
|
- Confirm every edit with the user before writing.
|
|
174
|
-
- If the request changes the change's *intent* rather than refining it,
|
|
209
|
+
- If the request changes the change's *intent* rather than refining it, ${INTENT_CHANGE_GUARDRAIL}.`
|
|
175
210
|
};
|
|
176
211
|
}
|
|
@@ -29,7 +29,7 @@ export declare const VALIDATION_MESSAGES: {
|
|
|
29
29
|
readonly DELTA_DESCRIPTION_EMPTY: "Delta description cannot be empty";
|
|
30
30
|
readonly PURPOSE_TOO_BRIEF: "Purpose section is too brief (less than 50 characters)";
|
|
31
31
|
readonly PURPOSE_IS_PLACEHOLDER: string;
|
|
32
|
-
readonly REQUIREMENT_TOO_LONG: "Requirement text is very long (>500 characters).
|
|
32
|
+
readonly REQUIREMENT_TOO_LONG: "Requirement text is very long (>500 characters). Move examples and edge cases into scenarios, or split it into separate requirements that each state one behavior.";
|
|
33
33
|
readonly DELTA_DESCRIPTION_TOO_BRIEF: "Delta description is too brief";
|
|
34
34
|
readonly DELTA_MISSING_REQUIREMENTS: "Delta should include requirements";
|
|
35
35
|
readonly GUIDE_NO_DELTAS: "No deltas found. Ensure your change has a specs/ directory with capability folders (e.g. specs/http-server/spec.md) containing .md files that use delta headers (## ADDED/MODIFIED/REMOVED/RENAMED Requirements) and that each requirement includes at least one \"#### Scenario:\" block. If this change intentionally modifies no specs (pure refactor, tooling, docs), set \"skip_specs: true\" in the change's .openspec.yaml instead. Tip: run \"openspec change show <change-id> --json --deltas-only\" to inspect parsed deltas.";
|
|
@@ -43,7 +43,7 @@ export const VALIDATION_MESSAGES = {
|
|
|
43
43
|
'writes for a new capability, or a `TBD`/`TODO` marker left in its place). Replace it with what this ' +
|
|
44
44
|
'capability is for, editing the main spec directly: a `## Purpose` in a delta is read only when the ' +
|
|
45
45
|
'capability is created, so it cannot replace this one.',
|
|
46
|
-
REQUIREMENT_TOO_LONG: `Requirement text is very long (>${MAX_REQUIREMENT_TEXT_LENGTH} characters).
|
|
46
|
+
REQUIREMENT_TOO_LONG: `Requirement text is very long (>${MAX_REQUIREMENT_TEXT_LENGTH} characters). Move examples and edge cases into scenarios, or split it into separate requirements that each state one behavior.`,
|
|
47
47
|
DELTA_DESCRIPTION_TOO_BRIEF: 'Delta description is too brief',
|
|
48
48
|
DELTA_MISSING_REQUIREMENTS: 'Delta should include requirements',
|
|
49
49
|
// Guidance snippets (appended to primary messages for remediation)
|
package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/change-parser.d.ts
CHANGED
|
@@ -6,22 +6,17 @@ export declare class ChangeParser extends MarkdownParser {
|
|
|
6
6
|
parseChangeWithDeltas(name: string): Promise<Change>;
|
|
7
7
|
private parseDeltaSpecs;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* `### Requirement: <name
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* as a requirement, which invented a scenario-less requirement that does not
|
|
15
|
-
* exist (#498): archive warned about a missing scenario, and `show --json`
|
|
16
|
-
* reported an extra delta. The delta reader already skips these headers and
|
|
17
|
-
* notes them, so this keeps the two readers in agreement.
|
|
18
|
-
*
|
|
19
|
-
* Overriding here rather than in MarkdownParser keeps main spec parsing —
|
|
20
|
-
* `view`, `list`, `spec --json`, spec validation — untouched.
|
|
9
|
+
* Reads requirements from a delta section, ignoring headers that are not
|
|
10
|
+
* `### Requirement: <name>` - a divider like `### Documentation
|
|
11
|
+
* Requirements` would otherwise be read as a scenario-less requirement,
|
|
12
|
+
* which the delta reader already skips and notes. Overriding here rather
|
|
13
|
+
* than in MarkdownParser keeps main spec parsing untouched.
|
|
21
14
|
*/
|
|
22
15
|
protected parseRequirements(section: Section): Requirement[];
|
|
16
|
+
/** The deltas in one spec file, read by parseDeltaSpec - the same reader archive applies. */
|
|
23
17
|
private parseSpecDeltas;
|
|
24
|
-
|
|
18
|
+
/** One Requirement per block, via the same section parser and header filter as before. */
|
|
19
|
+
private toRequirements;
|
|
25
20
|
private parseSectionsFromContent;
|
|
26
21
|
private getContentUntilNextHeaderFromLines;
|
|
27
22
|
}
|
package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/change-parser.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { MarkdownParser } from './markdown-parser.js';
|
|
2
2
|
import { buildCodeFenceMask } from './requirement-text.js';
|
|
3
|
+
import { parseDeltaSpec } from './requirement-blocks.js';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import { promises as fs } from 'fs';
|
|
5
6
|
import { discoverSpecFiles } from '../spec-discovery.js';
|
|
7
|
+
/** A header-only block for a REMOVED entry written in the bullet form. */
|
|
8
|
+
function removedNameBlock(name) {
|
|
9
|
+
const headerLine = `### Requirement: ${name}`;
|
|
10
|
+
return { headerLine, name, raw: headerLine };
|
|
11
|
+
}
|
|
6
12
|
export class ChangeParser extends MarkdownParser {
|
|
7
13
|
changeDir;
|
|
8
14
|
constructor(content, changeDir) {
|
|
@@ -19,13 +25,14 @@ export class ChangeParser extends MarkdownParser {
|
|
|
19
25
|
if (!whatChanges) {
|
|
20
26
|
throw new Error('Change must have a What Changes section');
|
|
21
27
|
}
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const deltas
|
|
28
|
+
// A spec file with a delta section is the only source of structured
|
|
29
|
+
// deltas, even when the section applies to nothing - else a bullet-form
|
|
30
|
+
// REMOVED fell through to the prose fallback below as an invented
|
|
31
|
+
// MODIFIED. The prose is used only when no spec file has a delta section:
|
|
32
|
+
// no spec files, or a legacy change with full future-state specs.
|
|
33
|
+
const specFiles = await discoverSpecFiles(path.join(this.changeDir, 'specs'));
|
|
34
|
+
const { deltas: specDeltas, hasDeltaSections } = await this.parseDeltaSpecs(specFiles);
|
|
35
|
+
const deltas = hasDeltaSections ? specDeltas : this.parseDeltas(whatChanges);
|
|
29
36
|
return {
|
|
30
37
|
name,
|
|
31
38
|
why: why.trim(),
|
|
@@ -37,37 +44,32 @@ export class ChangeParser extends MarkdownParser {
|
|
|
37
44
|
},
|
|
38
45
|
};
|
|
39
46
|
}
|
|
40
|
-
|
|
47
|
+
// specFiles comes from discoverSpecFiles, which walks specs/ recursively so
|
|
48
|
+
// nested layouts like specs/<area>/<capability>/spec.md are parsed too.
|
|
49
|
+
async parseDeltaSpecs(specFiles) {
|
|
41
50
|
const deltas = [];
|
|
42
|
-
|
|
43
|
-
// specs/<area>/<capability>/spec.md are parsed too (#1353)
|
|
44
|
-
const specFiles = await discoverSpecFiles(specsDir);
|
|
51
|
+
let hasDeltaSections = false;
|
|
45
52
|
for (const { id, specFile } of specFiles) {
|
|
46
53
|
try {
|
|
47
54
|
const content = await fs.readFile(specFile, 'utf-8');
|
|
48
|
-
const
|
|
49
|
-
|
|
55
|
+
const plan = parseDeltaSpec(content);
|
|
56
|
+
if (Object.values(plan.sectionPresence).some(Boolean))
|
|
57
|
+
hasDeltaSections = true;
|
|
58
|
+
deltas.push(...this.parseSpecDeltas(id, plan));
|
|
50
59
|
}
|
|
51
60
|
catch (error) {
|
|
52
61
|
// Spec file might not be readable, which is okay
|
|
53
62
|
continue;
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
|
-
return deltas;
|
|
65
|
+
return { deltas, hasDeltaSections };
|
|
57
66
|
}
|
|
58
67
|
/**
|
|
59
|
-
*
|
|
60
|
-
* `### Requirement: <name
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* as a requirement, which invented a scenario-less requirement that does not
|
|
65
|
-
* exist (#498): archive warned about a missing scenario, and `show --json`
|
|
66
|
-
* reported an extra delta. The delta reader already skips these headers and
|
|
67
|
-
* notes them, so this keeps the two readers in agreement.
|
|
68
|
-
*
|
|
69
|
-
* Overriding here rather than in MarkdownParser keeps main spec parsing —
|
|
70
|
-
* `view`, `list`, `spec --json`, spec validation — untouched.
|
|
68
|
+
* Reads requirements from a delta section, ignoring headers that are not
|
|
69
|
+
* `### Requirement: <name>` - a divider like `### Documentation
|
|
70
|
+
* Requirements` would otherwise be read as a scenario-less requirement,
|
|
71
|
+
* which the delta reader already skips and notes. Overriding here rather
|
|
72
|
+
* than in MarkdownParser keeps main spec parsing untouched.
|
|
71
73
|
*/
|
|
72
74
|
parseRequirements(section) {
|
|
73
75
|
return super.parseRequirements({
|
|
@@ -75,89 +77,64 @@ export class ChangeParser extends MarkdownParser {
|
|
|
75
77
|
children: section.children.filter((child) => /^Requirement:\s*\S/i.test(child.title.trim())),
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
|
-
|
|
80
|
+
/** The deltas in one spec file, read by parseDeltaSpec - the same reader archive applies. */
|
|
81
|
+
parseSpecDeltas(specName, plan) {
|
|
79
82
|
const deltas = [];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
operation: 'ADDED',
|
|
89
|
-
description: `Add requirement: ${req.text}`,
|
|
90
|
-
// Provide both single and plural forms for compatibility
|
|
91
|
-
requirement: req,
|
|
92
|
-
requirements: [req],
|
|
93
|
-
});
|
|
83
|
+
// Single and plural requirement fields are both filled for compatibility.
|
|
84
|
+
this.toRequirements(plan.added).forEach(req => {
|
|
85
|
+
deltas.push({
|
|
86
|
+
spec: specName,
|
|
87
|
+
operation: 'ADDED',
|
|
88
|
+
description: `Add requirement: ${req.text}`,
|
|
89
|
+
requirement: req,
|
|
90
|
+
requirements: [req],
|
|
94
91
|
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
operation: 'MODIFIED',
|
|
104
|
-
description: `Modify requirement: ${req.text}`,
|
|
105
|
-
requirement: req,
|
|
106
|
-
requirements: [req],
|
|
107
|
-
});
|
|
92
|
+
});
|
|
93
|
+
this.toRequirements(plan.modified).forEach(req => {
|
|
94
|
+
deltas.push({
|
|
95
|
+
spec: specName,
|
|
96
|
+
operation: 'MODIFIED',
|
|
97
|
+
description: `Modify requirement: ${req.text}`,
|
|
98
|
+
requirement: req,
|
|
99
|
+
requirements: [req],
|
|
108
100
|
});
|
|
109
|
-
}
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
101
|
+
});
|
|
102
|
+
// A bullet-form REMOVED entry carries only a name, read here as a
|
|
103
|
+
// header-form removal with no body.
|
|
104
|
+
const removedBlocks = [...plan.removedBlocks];
|
|
105
|
+
const removed = plan.removed.map((name) => {
|
|
106
|
+
const index = removedBlocks.findIndex((block) => block.name === name);
|
|
107
|
+
return index === -1 ? removedNameBlock(name) : removedBlocks.splice(index, 1)[0];
|
|
108
|
+
});
|
|
109
|
+
this.toRequirements(removed).forEach(req => {
|
|
110
|
+
deltas.push({
|
|
111
|
+
spec: specName,
|
|
112
|
+
operation: 'REMOVED',
|
|
113
|
+
description: `Remove requirement: ${req.text}`,
|
|
114
|
+
requirement: req,
|
|
115
|
+
requirements: [req],
|
|
122
116
|
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
spec: specName,
|
|
131
|
-
operation: 'RENAMED',
|
|
132
|
-
description: `Rename requirement from "${rename.from}" to "${rename.to}"`,
|
|
133
|
-
rename,
|
|
134
|
-
});
|
|
117
|
+
});
|
|
118
|
+
plan.renamed.forEach(rename => {
|
|
119
|
+
deltas.push({
|
|
120
|
+
spec: specName,
|
|
121
|
+
operation: 'RENAMED',
|
|
122
|
+
description: `Rename requirement from "${rename.from}" to "${rename.to}"`,
|
|
123
|
+
rename,
|
|
135
124
|
});
|
|
136
|
-
}
|
|
125
|
+
});
|
|
137
126
|
return deltas;
|
|
138
127
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
else if (toMatch) {
|
|
150
|
-
currentRename.to = toMatch[1].trim();
|
|
151
|
-
if (currentRename.from && currentRename.to) {
|
|
152
|
-
renames.push({
|
|
153
|
-
from: currentRename.from,
|
|
154
|
-
to: currentRename.to,
|
|
155
|
-
});
|
|
156
|
-
currentRename = {};
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return renames;
|
|
128
|
+
/** One Requirement per block, via the same section parser and header filter as before. */
|
|
129
|
+
toRequirements(blocks) {
|
|
130
|
+
return blocks.flatMap((block) => {
|
|
131
|
+
const [headerLine, ...body] = block.raw.split('\n');
|
|
132
|
+
// The delta reader also accepts `###Requirement:` with no space, which
|
|
133
|
+
// the section parser below would not see as a header.
|
|
134
|
+
const title = headerLine.replace(/^###\s*/, '').trim();
|
|
135
|
+
const [section] = this.parseSectionsFromContent([`### ${title}`, ...body].join('\n'));
|
|
136
|
+
return this.parseRequirements({ level: 2, title: '', content: '', children: [section] });
|
|
137
|
+
});
|
|
161
138
|
}
|
|
162
139
|
parseSectionsFromContent(content) {
|
|
163
140
|
const normalizedContent = ChangeParser.normalizeContent(content);
|
package/node_modules/@freeharness/sdd/dist/vendor/openspec/validation/parsers/markdown-parser.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { buildCodeFenceMask, extractRequirementText } from './requirement-text.js';
|
|
2
|
-
/**
|
|
3
|
-
* EARS scenario title: `Scenario: WHEN <event> THE SYSTEM SHALL <behavior>`
|
|
4
|
-
* (also WHILE/WHERE/IF ... SHALL). Case-insensitive; the title is the text
|
|
5
|
-
* after `#### ` so it still starts with `Scenario:`.
|
|
6
|
-
*/
|
|
7
|
-
const EARS_SCENARIO_TITLE = /^Scenario:\s*(?:WHEN|WHILE|WHERE|IF)\b[\s\S]*\b(?:SHALL|MUST)\b/i;
|
|
1
|
+
import { buildCodeFenceMask, extractRequirementText, hasScenarioBody, EARS_SCENARIO_TITLE } from './requirement-text.js';
|
|
8
2
|
export class MarkdownParser {
|
|
9
3
|
lines;
|
|
10
4
|
codeFenceLineMask;
|
|
@@ -136,8 +130,9 @@ export class MarkdownParser {
|
|
|
136
130
|
parseScenarios(requirementSection) {
|
|
137
131
|
const scenarios = [];
|
|
138
132
|
for (const scenarioSection of requirementSection.children) {
|
|
139
|
-
// Store the raw text content of the scenario section
|
|
140
|
-
|
|
133
|
+
// Store the raw text content of the scenario section. A header with no
|
|
134
|
+
// body is not a scenario; the delta counter applies the same rule.
|
|
135
|
+
if (hasScenarioBody(scenarioSection.content)) {
|
|
141
136
|
scenarios.push({
|
|
142
137
|
rawText: scenarioSection.content
|
|
143
138
|
});
|