-
Notifications
You must be signed in to change notification settings - Fork 7
Consume deterministic lookupId to simplify wizard provider resolution #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nicolehaugen
wants to merge
14
commits into
nicolehaugen-wizard-composition-artifact-cli
from
nicolehaugen-lookupid-wizard-simplification-d12
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
beeb3f8
Add lookup-id.mjs helper (parseLookupId, findLayerByLookupId)
nicolehaugen 4601188
Split lookupActiveLayer into lookupActiveLayerForCommand + lookupLaye…
nicolehaugen de5e86e
Attach lookupId additively to phase objects
nicolehaugen f2e011c
Switch commandSourcePath fallback to lookupId; add targeted tests
nicolehaugen 7cd91df
Switch computeProviderContributions to lookupId with hook-synthetic f…
nicolehaugen 6d47642
Upgrade artifact-cli.test.mjs pass-through asserts to behavioral look…
nicolehaugen e649b7c
Drop legacy lookupActiveLayer shim
nicolehaugen 117dfe2
Trim redundant test asserts already covered by lookup-id.test.mjs
nicolehaugen 3bd0777
Document hook-fallback removal dependency on spec-kit #4343 + applyHo…
nicolehaugen 20a6728
Revert comment expansion per user request
nicolehaugen 99084ad
Remove issue/PR number references from code comments
nicolehaugen c083228
Restore legacy source fallback in commandSourcePath for real preset c…
nicolehaugen f69df09
Pass resolver snapshot into lookupActiveLayerForCommand
Copilot 23e0253
Merge latest wizard artifact CLI base
nicolehaugen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ilot-wizard/extensions/speckit-wizard-canvas/test/compute-provider-contributions.test.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { describe, test } from "node:test"; | ||
| import { computeProviderContributions } from "../ui/composition.js"; | ||
|
|
||
| // computeProviderContributions buckets stack layers by provider id, tallying | ||
| // "customized" (core-inventory overrides) vs "added" (new) contributions. | ||
| // Bucket key resolution: prefer parseLookupId(layer.lookupId)?.providerId, | ||
| // falling back to sourceId for wizard-synthesized hook layers (which carry | ||
| // lookupId: null). | ||
|
|
||
| describe("computeProviderContributions", () => { | ||
| test("buckets a preset winner by lookupId providerId", () => { | ||
| const artifacts = [ | ||
| { | ||
| id: "commands/speckit.plan", | ||
| kind: "command", | ||
| stack: [ | ||
| { layer: "preset", presetId: "compliance", lookupId: "preset:compliance:command:speckit.plan" }, | ||
| ], | ||
| }, | ||
| ]; | ||
| const contributions = computeProviderContributions(artifacts); | ||
| assert.ok(contributions.has("compliance")); | ||
| }); | ||
|
|
||
| test("buckets an extension layer by lookupId providerId", () => { | ||
| const artifacts = [ | ||
| { | ||
| id: "templates/spec.md", | ||
| kind: "template", | ||
| stack: [ | ||
| { layer: "extension", extensionId: "foo", lookupId: "extension:foo:template:spec.md" }, | ||
| ], | ||
| }, | ||
| ]; | ||
| const contributions = computeProviderContributions(artifacts); | ||
| assert.ok(contributions.has("foo")); | ||
| }); | ||
|
|
||
| test("falls back to sourceId for hook-synthetic layers with lookupId: null", () => { | ||
| const artifacts = [ | ||
| { | ||
| id: "commands/some-hook-command", | ||
| kind: "hook", | ||
| hookBindings: [{ phase: "after_specify" }], | ||
| stack: [ | ||
| { layer: "extension", sourceId: "hooks-ext", lookupId: null }, | ||
| ], | ||
| }, | ||
| ]; | ||
| const contributions = computeProviderContributions(artifacts); | ||
| assert.ok(contributions.has("hooks-ext")); | ||
| }); | ||
|
|
||
| test("lookupId wins when a legacy presetId is also present", () => { | ||
| const artifacts = [ | ||
| { | ||
| id: "commands/speckit.plan", | ||
| kind: "command", | ||
| stack: [ | ||
| { | ||
| layer: "preset", | ||
| presetId: "legacy-id", | ||
| lookupId: "preset:compliance:command:speckit.plan", | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
| const contributions = computeProviderContributions(artifacts); | ||
| assert.ok(contributions.has("compliance")); | ||
| assert.ok(!contributions.has("legacy-id")); | ||
| }); | ||
| }); |
35 changes: 35 additions & 0 deletions
35
plugins/spec-kit-copilot-wizard/extensions/speckit-wizard-canvas/test/lookup-id.test.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { describe, test } from "node:test"; | ||
| import { parseLookupId } from "../ui/lookup-id.mjs"; | ||
|
|
||
| describe("parseLookupId", () => { | ||
| test("parses a preset command lookupId", () => { | ||
| assert.deepEqual( | ||
| parseLookupId("preset:compliance:command:speckit.plan"), | ||
| { providerKind: "preset", providerId: "compliance", kind: "command", name: "speckit.plan" }, | ||
| ); | ||
| }); | ||
|
|
||
| test("parses an extension template lookupId", () => { | ||
| assert.deepEqual( | ||
| parseLookupId("extension:foo:template:spec.md"), | ||
| { providerKind: "extension", providerId: "foo", kind: "template", name: "spec.md" }, | ||
| ); | ||
| }); | ||
|
|
||
| test("treats colons in <name> as opaque tail", () => { | ||
| const parsed = parseLookupId("preset:x:command:has:colons:in:name"); | ||
| assert.equal(parsed.name, "has:colons:in:name"); | ||
| assert.equal(parsed.providerId, "x"); | ||
| assert.equal(parsed.kind, "command"); | ||
| }); | ||
|
|
||
| test("returns null for null/empty/garbage/unknown-provider-kind input", () => { | ||
| assert.equal(parseLookupId(null), null); | ||
| assert.equal(parseLookupId(""), null); | ||
| assert.equal(parseLookupId("garbage"), null); | ||
| assert.equal(parseLookupId("core:x:y:z"), null); | ||
| assert.equal(parseLookupId(undefined), null); | ||
| assert.equal(parseLookupId("preset:x:y"), null); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
plugins/spec-kit-copilot-wizard/extensions/speckit-wizard-canvas/ui/lookup-id.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Pure helpers for the deterministic `lookupId` field carried on composition | ||
| // stack layers. | ||
| // | ||
| // Format: `preset:<presetId>:<kind>:<name>` or `extension:<extId>:<kind>:<name>`, | ||
| // `null` for core (built-in) layers. Stable across reinstalls; NOT a CLI | ||
| // round-trip key (do not send it back to `specify` commands). | ||
|
|
||
| const KNOWN_PROVIDER_KINDS = new Set(["preset", "extension"]); | ||
|
|
||
| // Parse a `lookupId` string into its constituent parts. Returns `null` for | ||
| // anything that isn't a recognized `preset:`/`extension:` lookupId (including | ||
| // `null`, empty string, garbage, or an unknown provider kind like `core:...`). | ||
| // | ||
| // Colons inside `<name>` are legal — everything after the third colon is | ||
| // treated as the opaque `name` tail (locked decision: do not split further). | ||
| export function parseLookupId(lookupId) { | ||
| if (typeof lookupId !== "string" || lookupId.length === 0) return null; | ||
| const parts = lookupId.split(":"); | ||
| if (parts.length < 4) return null; | ||
| const [providerKind, providerId, kind, ...nameParts] = parts; | ||
| if (!KNOWN_PROVIDER_KINDS.has(providerKind)) return null; | ||
| if (!providerId || !kind) return null; | ||
| const name = nameParts.join(":"); | ||
| if (!name) return null; | ||
| return { providerKind, providerId, kind, name }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.