Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
c8de3d1
Add ai-sdk attachments component, wire prompt-input demo layout
areebhammad Jul 26, 2026
ba37fe0
feat(core): add formwork-system node schema and wall construction fields
areebhammad Jul 26, 2026
2855679
feat(nodes): implement formwork-system geometry generator (shutter pa…
areebhammad Jul 26, 2026
5a81474
feat(nodes): add formwork controls to wall inspector panel
areebhammad Jul 26, 2026
c3392ac
test(mcp): add Bedrock tool-calling smoke test
areebhammad Jul 26, 2026
33b2456
feat(editor): replace hand-rolled Bedrock loop with Vercel AI SDK str…
areebhammad Jul 26, 2026
cac9ea5
feat(editor): add AI Elements chat UI components
areebhammad Jul 26, 2026
1b4ade1
feat(editor): add durable construction-plan workflow with human-in-th…
areebhammad Jul 26, 2026
bc00c9c
docs: add formwork-system implementation plan
areebhammad Jul 26, 2026
1865fc3
feat: update .gitignore to include .pi-subagents and example directory
areebhammad Jul 26, 2026
f0361da
feat: formwork double-sided shuttering, scaffold generation, inspecto…
areebhammad Jul 27, 2026
fa4625e
feat: add AI Elements components (shimmer, reasoning, suggestion, task)
areebhammad Jul 27, 2026
ee2e843
feat: AI chat panel improvements - context, attachments, history, sug…
areebhammad Jul 27, 2026
480a816
feat: archive old chat on New chat, show Previous conversations in em…
areebhammad Jul 27, 2026
7fd4bfc
fix: move suggestions above input box, clean archive previews
areebhammad Jul 27, 2026
f3053c9
fix: redesign chat empty state, derive archive preview at render time
areebhammad Jul 27, 2026
41c0fe2
fix: render injected context as badges in message bubble, not raw text
areebhammad Jul 27, 2026
b5b4cd7
fix: make context badge visible against user bubble (outline pill)
areebhammad Jul 27, 2026
f0c332c
fix: high-contrast context badge (primary tint + ring)
areebhammad Jul 27, 2026
17c6651
fix: remove empty-state hero (icon + heading + description)
areebhammad Jul 27, 2026
51a17d6
feat: add defender configuration with default mode patterns
areebhammad Jul 31, 2026
602f9eb
chore: add dist/src parity check to CI
areebhammad Aug 4, 2026
1498c9a
docs: add formwork reference — coverage, design, products
areebhammad Aug 4, 2026
9d1c23c
feat(core): model concrete pours in the schema
areebhammad Aug 4, 2026
281f83a
feat(core): migrate formwork-system nodes to formwork-assembly
areebhammad Aug 4, 2026
4f75dab
feat(core): add formwork measurement standards
areebhammad Aug 4, 2026
a9975e0
feat(core): add castable element abstraction and junction detection
areebhammad Aug 4, 2026
ffd620c
feat(core): measure opening deductions and junction trim
areebhammad Aug 4, 2026
d473d2e
feat(core): split castable elements into lifts and segments
areebhammad Aug 4, 2026
4257ad4
feat(core): derive pour units and their construction joints
areebhammad Aug 4, 2026
b8aa9ae
feat(core): classify which faces need forming, and why
areebhammad Aug 4, 2026
9b30dac
feat(core): add concrete pressure envelopes per standard
areebhammad Aug 4, 2026
cc89fca
feat(core): add formwork product catalog
areebhammad Aug 4, 2026
c6f7a20
feat(core): lay out panels, tie grids and clamp schedules
areebhammad Aug 4, 2026
4b57c3d
feat(core): export the formwork engine
areebhammad Aug 4, 2026
b399634
feat(nodes): add the construction-joint node
areebhammad Aug 4, 2026
c7cfade
feat(nodes): rebuild formwork-system as the per-kind formwork-assembly
areebhammad Aug 4, 2026
a5cd956
feat(nodes): add pour and formwork controls to host panels
areebhammad Aug 4, 2026
c0fea63
fix(nodes): re-derive host formwork when an opening moves or resizes
areebhammad Aug 4, 2026
5aa7996
feat(mcp): report formwork coverage from describe_node
areebhammad Aug 4, 2026
c75271e
test(mcp): cover pour sequencing through apply_patch
areebhammad Aug 4, 2026
8aa6cb2
feat(editor): extend the construction AI to columns and slabs
areebhammad Aug 4, 2026
cbffc56
docs: record formwork implementation status
areebhammad Aug 4, 2026
11475a7
refactor(core): move tie capacity helpers into the catalog
areebhammad Aug 5, 2026
cf45b92
feat(core): catalog the falsework parts — sheathing, beams, props
areebhammad Aug 5, 2026
5ac93b3
feat(core): the structural design chain — beam core, loads, both chains
areebhammad Aug 5, 2026
e09fd5d
feat(nodes): put the shutter on the plan and in the schedule
areebhammad Aug 5, 2026
9d4b801
feat(nodes): solve the wall pour once, and place what it returns
areebhammad Aug 5, 2026
2ec6536
refactor(nodes): move the column's solve into the shared design
areebhammad Aug 5, 2026
342ff79
feat(nodes): design the slab falsework instead of assuming it
areebhammad Aug 5, 2026
1d5f455
feat(nodes): let a spacing be calculated, and say so when it is stated
areebhammad Aug 5, 2026
a66a047
feat(nodes): render the design — the chain a user could not see
areebhammad Aug 5, 2026
ae0ae11
docs(formwork): record what landed, and what the report made urgent
areebhammad Aug 5, 2026
57942e1
feat(formwork): make the pour a project decision, not a constant
areebhammad Aug 6, 2026
7ac24ca
docs(formwork): the settings exist; the panel is what is missing
areebhammad Aug 6, 2026
abea8aa
feat(formwork): let the project state its pour, in the UI and to the AI
areebhammad Aug 6, 2026
1a2127d
feat(formwork): give the shutter parts, so it can be counted and ordered
areebhammad Aug 7, 2026
33b879d
fix(formwork): let the pour change without losing the shutter or the …
areebhammad Aug 8, 2026
47eaa66
feat(formwork): bill the floor, not the wall — project takeoff and CSV
areebhammad Aug 8, 2026
5add24a
feat(formwork): let the engine say a bill is for something unbuildable
areebhammad Aug 8, 2026
0d8d005
feat(formwork): show a user whether the bill can be built
areebhammad Aug 8, 2026
37520e7
feat(formwork): report the tie the shutter chose not to draw
areebhammad Aug 8, 2026
2b588a2
feat(mcp): the formwork questions, askable from outside the editor
areebhammad Aug 8, 2026
dc12413
docs(mcp): reconstruct the five releases the changelog missed
areebhammad Aug 8, 2026
379fe05
docs(formwork): fix a tally the last change left one short
areebhammad Aug 8, 2026
7fdec45
fix(editor): an AI edit the user can take back
areebhammad Aug 8, 2026
7ea987b
feat(formwork): two corner units where there is room for one
areebhammad Aug 9, 2026
e208655
fix(editor): a production build that could not ship, while every gate…
areebhammad Aug 9, 2026
5f85b89
fix(mcp): 81 MB of glTF in a JSON API route, reported in a warning no…
areebhammad Aug 9, 2026
32ca8ad
feat(formwork): the tie that leaks — a rod through the water seal
areebhammad Aug 9, 2026
444519c
feat(formwork): say whose rack the bill comes off
areebhammad Aug 9, 2026
89e8bd7
docs(formwork): the counts the doc quotes are the counts the suites run
areebhammad Aug 9, 2026
33ae1e0
feat(formwork): say how long the bill is held, not only what is on it
areebhammad Aug 9, 2026
3185f74
fix(core): keep bomHire off the root barrel, where it cannot be called
areebhammad Aug 9, 2026
f65b2a9
feat(formwork): let an outside agent state the pour, not only read th…
areebhammad Aug 9, 2026
43ea200
feat(formwork): let an agent name one part of a shutter, and refuse a…
areebhammad Aug 9, 2026
029841d
feat(formwork): close the MCP surface — the pour, and the tools its r…
areebhammad Aug 9, 2026
86b20ba
feat(formwork): what the bill costs to hold, priced from the project'…
areebhammad Aug 10, 2026
c121d33
feat(formwork): say when the pour happens, so the bill can be booked
areebhammad Aug 10, 2026
048a0e5
feat(formwork): count the sets, because a bill is not an order
areebhammad Aug 10, 2026
0c212fb
feat(formwork): what the job is short of, and whether to own it
areebhammad Aug 10, 2026
207e83f
feat(formwork): which pour is free to move, and what moving it costs
areebhammad Aug 10, 2026
17e1872
feat(formwork): cost the gang's time, beside the plant's and never in…
Aug 11, 2026
70e4994
feat(formwork): tell a date somebody typed from a date somebody agree…
Aug 11, 2026
43a5016
feat(formwork): what the crane lifts at a time, and what it costs to …
Aug 12, 2026
a62b657
feat(formwork): say how many sheets to buy the boards out of
Aug 12, 2026
3006443
feat(formwork): a finding that says what would clear it, and one that…
Aug 12, 2026
f7c90d1
feat(formwork): the findings that are not ours to fix
Aug 13, 2026
a3c652d
feat(formwork): the nest a carpenter can cut from
Aug 13, 2026
5eea63a
feat(formwork): which rectangle each mark is
Aug 13, 2026
300e6d6
feat(formwork): let the reader take the move, then measure whether it…
Aug 13, 2026
7908ed2
docs(formwork): specify the 12% that prose could only gesture at
Aug 13, 2026
7ce7172
feat(formwork): the same job, built in the other system
Aug 13, 2026
957ddf5
feat(formwork): the rate somebody can actually pour at
Aug 13, 2026
6f84abd
feat(formwork): the joint the engineer drew is now a cut
Aug 13, 2026
9511790
feat(formwork): which sheets to buy, and where the saw starts
Aug 13, 2026
f4b610c
docs(formwork): the desk as it actually is
Aug 13, 2026
5e659e5
feat(formwork): a panel's life, rather than a rent the yard never pays
Aug 13, 2026
8c5743f
feat(formwork): the concrete has to arrive
Aug 13, 2026
df48713
docs(formwork): tick the boxes the last four sessions filled
Aug 13, 2026
23bea70
docs(formwork): the pipeline had already shipped, and two task groups…
Aug 13, 2026
26a92a6
feat(formwork): the element that left the bill without saying so
Aug 13, 2026
1f1810b
feat(formwork): where a lift joint may land
Aug 14, 2026
6905033
feat(formwork): alternate-bay parity — the two sides of a boundary cu…
Aug 14, 2026
fb8af11
feat(formwork): the strength/maturity striking criterion beside the e…
Aug 14, 2026
ddb5bb1
feat(formwork): a registered system with no data refuses rather than …
Aug 14, 2026
faa1d98
feat(formwork): a repeated floor is cut once, a dead asset is replace…
Aug 14, 2026
4a459d3
feat(formwork): the money reaches the CSV, the systems declare what t…
Aug 14, 2026
b5fed80
feat(formwork): a system declares what it forms, the weakest source t…
Aug 14, 2026
6fd1436
feat(formwork): the tie meets its cage, the prop meets its floor, and…
Aug 14, 2026
52c2dfd
docs(openspec): the eight formwork capability specs reach the main tree
Aug 14, 2026
2940ca6
feat(formwork): the cheaper way to form the same building, named and …
Aug 14, 2026
94f50c3
feat(formwork): a saving can be taken, and every document now states …
Aug 14, 2026
af7734f
docs(openspec): archive the formwork-plan-remainder change, keeping t…
Aug 14, 2026
2f16996
docs(formwork): the P6 row said no maturity after the strength criter…
Aug 14, 2026
9b42760
feat(formwork): the architect's grid, a void former, and the fourth c…
Aug 14, 2026
29d9558
fix(formwork): a wall or slab hosting a box-out survived nothing — th…
Aug 14, 2026
f7669c2
feat(formwork): the void can now be created, and the beam can be draw…
Aug 14, 2026
b5520e1
feat(formwork): the first manufacturer-published metric ply, and the …
Aug 14, 2026
8b340be
feat(formwork): the WISA entries rolling shear is now published too
Aug 14, 2026
b68e87f
feat(beam): a placed beam can now be moved, reshaped and seen in plan
Aug 14, 2026
cb3449b
feat(beam): depth arrow grows the section without the inspector
Aug 14, 2026
014b6bc
test(formwork): the beam resolves end to end in the MCP — sides and p…
Aug 14, 2026
7c12e76
feat(formwork): CESMM4 verified at 0.5 m2, and the EN 13670 citation …
Aug 14, 2026
128ec12
feat(formwork): beams meeting at a corner stay one junction
Aug 14, 2026
cf11cf1
feat(formwork): the angle pill reads the meeting beam at a junction
Aug 14, 2026
523bc59
feat(formwork): the plan shows the junction angle, and the move drag …
Aug 14, 2026
295b745
feat(formwork): the plan shows the junction angle on walls too, from …
Aug 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .agents/skills/.openspec-target
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
codex
185 changes: 185 additions & 0 deletions .agents/skills/openspec-apply-change/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
---
name: openspec-apply-change
description: Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
allowed-tools: Bash(openspec:*)
license: MIT
compatibility: Requires openspec CLI.
metadata:
author: openspec
version: "1.0"
generatedBy: "1.8.0"
---

Implement tasks from an OpenSpec change.

**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.

**Input**: Optionally specify a change name (e.g., `$openspec-apply-change (Codex) or /openspec-apply-change (other agents) add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.

**Steps**

1. **Select the change**

If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one

Always announce: "Using change: <name>" and how to override (e.g., `$openspec-apply-change (Codex) or /openspec-apply-change (other agents) <other>`).

2. **Check status to understand the schema**
```bash
openspec status --change "<name>" --json
```
Parse the JSON to understand:
- `schemaName`: The workflow being used (e.g., "spec-driven")
- `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)

3. **Get apply instructions**

```bash
openspec instructions apply --change "<name>" --json
```

This returns:
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
- Progress (total, complete, remaining)
- Task list with status
- Dynamic instruction based on current state
- Optional `context`: current required project instruction input from the selected root
- Optional `operationGuidance`: current advisory guidance for apply

**Handle states:**
- If `state: "blocked"` (missing artifacts): show message, suggest using `$openspec-continue-change (Codex) or /openspec-continue-change (other agents)` (if it is not installed, run `openspec status --change "<name>" --json` to see the next artifact and `openspec instructions <artifact-id> --change "<name>" --json` for how to create it)
- If `state: "all_done"`: congratulate, suggest archive
- Otherwise: proceed to implementation

Treat `context` as a required prompt-level input. Read and consider it, and
apply relevant project facts, conventions, and constraints while implementing.
Treat `operationGuidance` as optional additive advice. Read and consider every
entry, and follow entries that are applicable and compatible with the built-in
workflow.

Keep both fields separate from CLI-returned state, missing artifacts, tasks,
progress, `contextFiles`, and the built-in `instruction`. They are not
evidence of task completion, do not replace the built-in instruction, and do
not permit bypassing a blocked state. If context conflicts with the built-in
instruction, an explicit user choice, or a CLI-controlled value, report the
conflict and preserve the controlling value. If guidance is inapplicable or
conflicts with those controlling inputs, do not follow it and explain why.
These are prompt-level behavior contracts, not enforceable checks.

4. **Read context files**

Read every file path listed under `contextFiles` from the apply instructions output.
The files depend on the schema being used:
- **spec-driven**: proposal, specs, design, tasks
- Other schemas: follow the contextFiles from CLI output

Do not copy `context` or `operationGuidance` verbatim into implementation
files or planning artifacts unless the user separately asks for that content.

5. **Show current progress**

Display:
- Schema being used
- Progress: "N/M tasks complete"
- Remaining tasks overview
- Dynamic instruction from CLI

6. **Implement tasks (loop until done or blocked)**

For each pending task:
- Show which task is being worked on
- Make the code changes required
- Keep changes minimal and focused
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
- Continue to next task

**Pause if:**
- Task is unclear → ask for clarification
- Implementation reveals a design issue → suggest updating artifacts
- Error or blocker encountered → report and wait for guidance
- User interrupts

7. **On completion or pause, show status**

Display:
- Tasks completed this session
- Overall progress: "N/M tasks complete"
- If all done: suggest archive
- If paused: explain why and wait for guidance

**Output During Implementation**

```
## Implementing: <change-name> (schema: <schema-name>)

Working on task 3/7: <task description>
[...implementation happening...]
✓ Task complete

Working on task 4/7: <task description>
[...implementation happening...]
✓ Task complete
```

**Output On Completion**

```
## Implementation Complete

**Change:** <change-name>
**Schema:** <schema-name>
**Progress:** 7/7 tasks complete ✓

### Completed This Session
- [x] Task 1
- [x] Task 2
...

All tasks complete! You can archive this change with `$openspec-archive-change (Codex) or /openspec-archive-change (other agents)`.
```

**Output On Pause (Issue Encountered)**

```
## Implementation Paused

**Change:** <change-name>
**Schema:** <schema-name>
**Progress:** 4/7 tasks complete

### Issue Encountered
<description of the issue>

**Options:**
1. <option 1>
2. <option 2>
3. Other approach

What would you like to do?
```

**Guardrails**
- Keep going through tasks until done or blocked
- Always read context files before starting (from the apply instructions output)
- If task is ambiguous, pause and ask before implementing
- If implementation reveals issues, pause and suggest artifact updates
- Keep code changes minimal and scoped to each task
- Update task checkbox immediately after completing each task
- Pause on errors, blockers, or unclear requirements - don't guess
- Use contextFiles from CLI output, don't assume specific file names
- Do not use context or operation guidance as proof that a task is complete
- Apply relevant project context; report conflicts with controlling workflow inputs
- Consider every guidance entry; explain any inapplicable or conflicting advice
- Do not copy runtime context or operation guidance into implementation files or planning artifacts
- Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria

**Fluid Workflow Integration**

This skill supports the "actions on a change" model:

- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
182 changes: 182 additions & 0 deletions .agents/skills/openspec-archive-change/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
---
name: openspec-archive-change
description: Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
allowed-tools: Bash(openspec:*)
license: MIT
compatibility: Requires openspec CLI.
metadata:
author: openspec
version: "1.0"
generatedBy: "1.8.0"
---

Archive a completed change in the experimental workflow.

**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.

`<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.

**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.

**Steps**

1. **Select the change**

If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one

When prompting, show only active changes (not already archived).
Include the schema used for each change if available.

Always announce: "Using change: <name>" and how to override (e.g., `$openspec-archive-change (Codex) or /openspec-archive-change (other agents) <other>`).

**Load current archive inputs before the existing archive checks:**

After resolving the selected change and planning root, run:
```bash
openspec instructions archive --change "<name>" --json
```
Keep the same selected-root flags on this command. This lookup is advisory and
optional: it only supplies extra prompt inputs, so it must never block archiving.
If it exits non-zero or returns invalid JSON — for example on an older CLI that
does not support this command yet — continue the archive workflow with no
context and no operation guidance. Do not report an error and do not stop.

A successful response may omit both optional fields. Treat `context` as a
required prompt-level input: read and consider it, and apply relevant project
facts, conventions, and constraints. Treat `operationGuidance` as optional
additive advice: read and consider every entry, and follow entries that are
applicable and compatible with the built-in archive workflow.

Keep both fields separate from built-in steps, explicit user choices, resolved
paths, CLI checks, and command contracts. If context conflicts with one of those
controlling inputs, report the conflict and preserve the controlling value. If
guidance is inapplicable or conflicts with a controlling input, do not follow it
and explain why. Do not infer replacement paths, skipped prompts, or flags from
either field, and do not copy their text verbatim into specs, change artifacts,
or archive summaries unless the user separately asks for it. These are
prompt-level behavior contracts, not enforceable checks.

2. **Check artifact completion status**

Run `openspec status --change "<name>" --json` to check artifact completion.

Parse the JSON to understand:
- `schemaName`: The workflow being used
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
- `artifacts`: List of artifacts with their status (`done`, `skipped`, or other)

**If any artifacts are neither `done` nor `skipped`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
- Display warning listing incomplete artifacts
- Ask the user to confirm they want to proceed
- Proceed if user confirms

3. **Check task completion status**

Read the tasks file (typically `tasks.md`) to check for incomplete tasks.

Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).

**If incomplete tasks found:**
- Display warning showing count of incomplete tasks
- Ask the user to confirm they want to proceed
- Proceed if user confirms

**If no tasks file exists:** Proceed without task-related warning.

4. **Assess delta spec sync state**

Use `artifactPaths.specs.existingOutputPaths` from status JSON as the only
delta-spec source. If the `specs` entry is missing or
`existingOutputPaths` is empty, proceed without a sync prompt and do not infer
delta specs from other artifacts.

**If delta specs exist:**
- Compare each delta spec with its corresponding main spec at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (use the store-aware `planningHome.root` from step 2, not a hardcoded repo path)
- Determine what changes would be applied (adds, modifications, removals, renames)
- Show a combined summary before prompting

**Prompt options:**
- If changes needed: "Sync now (recommended)", "Archive without syncing"
- If already synced: "Archive now", "Sync anyway", "Cancel"

Route on the answer:
- "Cancel" — stop, do not archive
- "Archive without syncing" or "Archive now" — proceed to archive
- "Sync now" or "Sync anyway" — sync, then verify (below)
- Anything else — ask again rather than archiving

Before a selected sync writes any main spec, run
`openspec instructions specs --change "<name>" --json` once with the same
selected-root flags. Require a zero exit status and valid artifact-instruction
JSON. If the lookup fails or returns invalid JSON, report the error and stop
before writing any main spec or moving the change. A valid response with omitted
`rules` is the no-rules case. Apply returned `rules` only to the content and
form of main specs produced by this merge; do not use them as archive guidance,
change CLI behavior, or copy the rule text into any output file.

Then run the `openspec-sync-specs` workflow inline (agent-driven intelligent merge) for change '<name>', passing the delta spec analysis and the fetched specs-rule snapshot from above, and wait for it to finish. The inline sync must reuse that snapshot without fetching `specs` instructions again. Do not delegate it to a background task — step 5 would move `changeRoot` out from under a sync that is still reading it, leaving the change archived and the main specs never updated. If your agent can only run it by delegation, delegate synchronously and wait for the result.

Then re-run the comparison from the top of this step against every capability that has a delta spec in `artifactPaths.specs.existingOutputPaths` — not only the ones the sync reports it touched. A successful sync leaves nothing left to apply, so each capability must now read as already synced:
- ADDED requirements present
- MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
- REMOVED requirements gone — and where this sync retired a capability (removed its last requirement, leaving `## Requirements` empty), its main spec deleted rather than left empty; a spec the sync deliberately kept and reported is also a match
- RENAMED requirements present under the new name and absent under the old one

If the sync failed, or any capability does not match, report what differs and stop — do not archive. Nothing has moved and `changeRoot` is intact, so the user can fix the mismatch or re-run the sync and start the archive again.

5. **Perform the archive**

Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
```bash
mkdir -p "<planningHome.changesDir>/archive"
```

Generate the target name: use the change name as-is when it already starts with a `YYYY-MM-DD-` prefix; otherwise prepend the current date as `YYYY-MM-DD-<change-name>`. Never stack a second date (same rule as `openspec archive`).

**Check if target already exists:**
- If yes: Fail with error, suggest renaming existing archive or using different date
- If no: Move `changeRoot` to the archive directory

```bash
mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
```

6. **Display summary**

Show archive completion summary including:
- Change name
- Schema that was used
- Archive location
- Whether specs were synced (if applicable)
- Note about any warnings (incomplete artifacts/tasks)

**Output On Success**

```markdown
## Archive Complete

**Change:** <change-name>
**Schema:** <schema-name>
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
**Specs:** <"✓ Synced to main specs" only if the step 4 verification passed; otherwise "No delta specs" or "Sync skipped">

<"All artifacts complete. All tasks complete." — or, if archived with warnings, list them instead (e.g. "Archived with 2 incomplete tasks")>
```

**Guardrails**
- Announce the selected change; prompt for selection when it is ambiguous
- Use artifact graph (openspec status --json) for completion checking
- Don't block archive on warnings - just inform and confirm
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
- Show clear summary of what happened
- If sync is requested, run the `openspec-sync-specs` workflow inline (agent-driven)
- Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving `changeRoot`
- If delta specs exist, always run the sync assessment and show the combined summary before prompting
- Apply relevant runtime context and report conflicts; operation guidance remains advisory
- Consider every guidance entry and explain any inapplicable or conflicting advice
- Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
- Artifact rules constrain only the specs being written and are never operation guidance
- Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files
Loading