toolcraft-openapi 0.0.26 → 0.0.33
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/dist/auth/bearer-token-auth.js +1 -1
- package/dist/bin/generate.d.ts +9 -1
- package/dist/bin/generate.js +65 -9
- package/dist/error-codes.d.ts +1 -0
- package/dist/error-codes.js +6 -0
- package/dist/generate.d.ts +20 -3
- package/dist/generate.js +604 -144
- package/dist/http.d.ts +17 -1
- package/dist/http.js +113 -7
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -0
- package/dist/inspect-source.d.ts +10 -0
- package/dist/inspect-source.js +14 -0
- package/dist/inspect.d.ts +22 -0
- package/dist/inspect.js +171 -0
- package/dist/interpreter.js +6 -2
- package/dist/mock/fetch.js +28 -12
- package/dist/mock/forgeyard.d.ts +4 -0
- package/dist/mock/forgeyard.js +452 -0
- package/dist/mock.d.ts +1 -0
- package/dist/mock.js +1 -0
- package/dist/naming.d.ts +4 -1
- package/dist/naming.js +93 -7
- package/dist/network-error.js +29 -12
- package/dist/normalize-swagger.d.ts +2 -0
- package/dist/normalize-swagger.js +201 -0
- package/dist/render-inspection.d.ts +2 -0
- package/dist/render-inspection.js +130 -0
- package/dist/request-shape.d.ts +4 -0
- package/dist/request-shape.js +1 -0
- package/dist/runtime.js +7 -1
- package/dist/spec-source.js +7 -4
- package/node_modules/auth-store/dist/create-secret-store.js +6 -1
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +1 -1
- package/node_modules/auth-store/dist/encrypted-file-store.js +32 -28
- package/node_modules/auth-store/dist/error-codes.d.ts +1 -0
- package/node_modules/auth-store/dist/error-codes.js +5 -0
- package/node_modules/auth-store/dist/keychain-store.js +23 -8
- package/node_modules/toolcraft-design/README.md +148 -0
- package/node_modules/toolcraft-design/dist/components/catalog.d.ts +26 -0
- package/node_modules/toolcraft-design/dist/components/catalog.js +94 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/index.d.ts +2 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/index.js +1 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/footer.js +1 -2
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/output-pane.js +16 -19
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/stats-pane.js +1 -15
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/demo.js +2 -2
- package/node_modules/toolcraft-design/dist/explorer/theme.js +29 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/index.d.ts +7 -1
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/index.js +4 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/theme-detect.d.ts +1 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/theme-detect.js +28 -6
- package/node_modules/toolcraft-design/dist/internal/theme-state.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.js +35 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/theme.d.ts +1 -1
- package/node_modules/toolcraft-design/dist/prompts/theme.js +15 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/frontmatter.js +50 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.js +85 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/index.d.ts +2 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/index.js +1 -0
- package/node_modules/toolcraft-design/package.json +42 -0
- package/package.json +8 -6
- package/node_modules/@poe-code/design-system/dist/explorer/theme.js +0 -97
- package/node_modules/@poe-code/design-system/dist/prompts/theme.js +0 -12
- package/node_modules/@poe-code/design-system/dist/tokens/colors.d.ts +0 -35
- package/node_modules/@poe-code/design-system/dist/tokens/colors.js +0 -34
- package/node_modules/@poe-code/design-system/package.json +0 -29
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/components.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/components.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/writer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/writer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/browser.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/browser.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/color.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/color.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/command-errors.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/command-errors.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/detail-card.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/detail-card.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter-plain.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter-plain.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/logger.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/logger.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/symbols.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/symbols.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/table.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/table.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/template.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/template.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/text.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/text.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/ansi.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/ansi.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/buffer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/buffer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/border.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/border.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/footer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/output-pane.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/stats-pane.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/dashboard.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/dashboard.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/demo.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/demo.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/keymap.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/keymap.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/layout.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/layout.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/should-use-dashboard.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/should-use-dashboard.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/snapshot.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/snapshot.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/store.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/store.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal-width.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal-width.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/types.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/types.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/actions.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/actions.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/demo.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/events.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/events.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/filter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/filter.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/jobs.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/jobs.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/keymap.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/keymap.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/layout.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/layout.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/reducer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/reducer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/detail.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/detail.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/footer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/footer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/header.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/header.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/list.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/list.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/modal.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/modal.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/test-fixtures.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/test-fixtures.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/text.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/text.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.test-helpers.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.test-helpers.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/state.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/state.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/theme.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/color-support.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/color-support.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/output-format.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/output-format.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/strip-ansi.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/strip-ansi.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/cancel.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/cancel.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/intro.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/intro.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/log.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/log.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/note.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/note.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/outro.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/outro.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/spinner.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/spinner.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/menu.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/menu.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/spinner.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/spinner.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/ast.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/ast.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/demo-content.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/demo-content.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/block.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/block.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/frontmatter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/inline.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/inline.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/renderer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/renderer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/testing/theme-render-fixture.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/testing/theme-render-fixture.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/spacing.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/spacing.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/typography.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/typography.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/widths.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/widths.js +0 -0
|
@@ -12,8 +12,8 @@ export class KeychainStore {
|
|
|
12
12
|
}
|
|
13
13
|
async get() {
|
|
14
14
|
const result = await this.executeSecurityCommand(["find-generic-password", "-s", this.service, "-a", this.account, "-w"], "read secret from macOS Keychain");
|
|
15
|
-
if (result
|
|
16
|
-
return stripTrailingLineBreak(result
|
|
15
|
+
if (getCommandExitCode(result) === 0) {
|
|
16
|
+
return stripTrailingLineBreak(getCommandOutput(result, "stdout"));
|
|
17
17
|
}
|
|
18
18
|
if (isKeychainEntryNotFound(result)) {
|
|
19
19
|
return null;
|
|
@@ -33,13 +33,13 @@ export class KeychainStore {
|
|
|
33
33
|
"-U",
|
|
34
34
|
"-w"
|
|
35
35
|
], "store secret in macOS Keychain", { stdin: value });
|
|
36
|
-
if (result
|
|
36
|
+
if (getCommandExitCode(result) !== 0) {
|
|
37
37
|
throw createSecurityCliFailure("store secret in macOS Keychain", result);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async delete() {
|
|
41
41
|
const result = await this.executeSecurityCommand(["delete-generic-password", "-s", this.service, "-a", this.account], "delete secret from macOS Keychain");
|
|
42
|
-
if (result
|
|
42
|
+
if (getCommandExitCode(result) === 0 || isKeychainEntryNotFound(result)) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
throw createSecurityCliFailure("delete secret from macOS Keychain", result);
|
|
@@ -121,12 +121,27 @@ function stripTrailingLineBreak(value) {
|
|
|
121
121
|
return value;
|
|
122
122
|
}
|
|
123
123
|
function isKeychainEntryNotFound(result) {
|
|
124
|
-
return result
|
|
124
|
+
return getCommandExitCode(result) === KEYCHAIN_ITEM_NOT_FOUND_EXIT_CODE;
|
|
125
125
|
}
|
|
126
126
|
function createSecurityCliFailure(operation, result) {
|
|
127
|
-
const
|
|
127
|
+
const exitCode = getCommandExitCode(result);
|
|
128
|
+
const details = getCommandOutput(result, "stderr").trim()
|
|
129
|
+
|| getCommandOutput(result, "stdout").trim();
|
|
128
130
|
if (details) {
|
|
129
|
-
return new Error(`Failed to ${operation}: security exited with code ${
|
|
131
|
+
return new Error(`Failed to ${operation}: security exited with code ${exitCode}: ${details}`);
|
|
130
132
|
}
|
|
131
|
-
return new Error(`Failed to ${operation}: security exited with code ${
|
|
133
|
+
return new Error(`Failed to ${operation}: security exited with code ${exitCode}`);
|
|
134
|
+
}
|
|
135
|
+
function getCommandExitCode(result) {
|
|
136
|
+
const value = getOwnEntry(result, "exitCode");
|
|
137
|
+
return typeof value === "number" && Number.isInteger(value) ? value : 1;
|
|
138
|
+
}
|
|
139
|
+
function getCommandOutput(result, key) {
|
|
140
|
+
const value = getOwnEntry(result, key);
|
|
141
|
+
return typeof value === "string" ? value : "";
|
|
142
|
+
}
|
|
143
|
+
function getOwnEntry(record, key) {
|
|
144
|
+
return Object.prototype.hasOwnProperty.call(record, key)
|
|
145
|
+
? record[key]
|
|
146
|
+
: undefined;
|
|
132
147
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# toolcraft-design
|
|
2
|
+
|
|
3
|
+
Shared terminal design system for Toolcraft applications. It provides design tokens, ANSI-aware text and layout components, interactive prompts, dashboards, explorers, terminal Markdown rendering, and deterministic static renderers from one package.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install toolcraft-design
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Import from the package root:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { configureTheme, promptText, renderMarkdown, renderTable, text } from "toolcraft-design";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The package does not expose public subpath imports.
|
|
18
|
+
|
|
19
|
+
## Public API
|
|
20
|
+
|
|
21
|
+
### Tokens
|
|
22
|
+
|
|
23
|
+
- `tokens`: namespace containing the token exports.
|
|
24
|
+
- `brand`: the default purple brand color.
|
|
25
|
+
- `dark`, `light`: built-in purple `ThemePalette` values.
|
|
26
|
+
- `brands`: mutable registry of available brands.
|
|
27
|
+
- `spacing`, `typography`, `widths`: shared design token collections.
|
|
28
|
+
- Types: `Brand`, `ThemeName`, `ThemePalette`.
|
|
29
|
+
|
|
30
|
+
### Components
|
|
31
|
+
|
|
32
|
+
- `text`, `color`, `symbols`: text styles, color helpers, and terminal symbols.
|
|
33
|
+
- `createLogger`, `logger`: styled logger creation and the default logger.
|
|
34
|
+
- `helpFormatter`, `helpFormatterPlain`: styled and plain help formatting APIs.
|
|
35
|
+
- `formatColumns`, `formatCommand`, `formatUsage`, `formatOption`, `formatCommandList`, `formatOptionList`: individual help-formatting functions.
|
|
36
|
+
- `formatCommandNotFound`, `formatCommandNotFoundPanel`: command error rendering.
|
|
37
|
+
- `renderTable`, `renderDetailCard`: tabular and detail-card rendering.
|
|
38
|
+
- `getTemplatePartialNames`, `renderTemplate`, `resolveTemplatePartials`: template rendering utilities.
|
|
39
|
+
- `openExternal`: opens a URL or file with the platform browser command.
|
|
40
|
+
- Types: `Color`, `LoggerOutput`, `CommandInfo`, `OptionInfo`, `FormatColumnsOptions`, `TableColumn`, `RenderTableOptions`, `DetailCardRow`, `DetailCardSection`, `RenderDetailCardOptions`, `RenderTemplateOptions`, `TemplateEscape`.
|
|
41
|
+
|
|
42
|
+
### Prompts
|
|
43
|
+
|
|
44
|
+
- `prompts`: namespace containing the prompt exports.
|
|
45
|
+
- `intro`, `introPlain`, `outro`, `note`: prompt flow presentation.
|
|
46
|
+
- `select`, `multiselect`, `promptText`, `confirm`, `confirmOrCancel`, `password`: interactive inputs. The prompt text function is exported as `promptText` at the package root and as `text` on `prompts`.
|
|
47
|
+
- `spinner`, `withSpinner`: spinner APIs.
|
|
48
|
+
- `isCancel`, `cancel`, `log`, `PromptCancelledError`: cancellation and prompt logging utilities.
|
|
49
|
+
- `promptTheme`: the brand-aware prompt theme.
|
|
50
|
+
- Types: `SelectOptions`, `MultiselectOptions`, `TextOptions`, `ConfirmOptions`, `PasswordOptions`, `SpinnerOptions`, `WithSpinnerOptions`.
|
|
51
|
+
|
|
52
|
+
### Dashboard
|
|
53
|
+
|
|
54
|
+
- `dashboard`: namespace containing the complete dashboard API.
|
|
55
|
+
- `createDashboard`, `shouldUseInteractiveDashboard`: root-level dashboard exports.
|
|
56
|
+
- Root-level types: `Dashboard`, `DashboardOptions`.
|
|
57
|
+
- The namespace also exports `renderDashboardSnapshot`, `defaultHints`, and the dashboard snapshot, state, output, command, statistics, and footer-hint types.
|
|
58
|
+
|
|
59
|
+
### Explorer
|
|
60
|
+
|
|
61
|
+
- `explorer`: namespace containing the complete explorer API.
|
|
62
|
+
- `runExplorer`, `singleDetail`: root-level explorer exports.
|
|
63
|
+
- Root-level types: `Row`, `DetailItem`, `Detail`, `DetailCtx`, `Action`, `ActionContext`, `ExplorerConfig`, `ReorderContext`, `Tone`.
|
|
64
|
+
- The namespace also exports `createInitialState`, `resolveBindings`, and the remaining explorer event, binding, layout, size, state, and effect types.
|
|
65
|
+
|
|
66
|
+
### Terminal Markdown
|
|
67
|
+
|
|
68
|
+
- `parse`: parses Markdown into `MdNode` values.
|
|
69
|
+
- `render`: renders parsed Markdown nodes for the terminal.
|
|
70
|
+
- `renderMarkdown`: parses and renders a Markdown string.
|
|
71
|
+
- Types: `MdNode`, `RenderOptions`.
|
|
72
|
+
|
|
73
|
+
### Static Rendering
|
|
74
|
+
|
|
75
|
+
- `staticRender`: namespace containing the static rendering exports.
|
|
76
|
+
- `SPINNER_FRAMES`, `renderSpinnerFrame`, `renderSpinnerStopped`: deterministic spinner rendering.
|
|
77
|
+
- `renderMenu`: deterministic menu rendering.
|
|
78
|
+
- Types: `SpinnerFrameOptions`, `SpinnerStoppedOptions`, `MenuOption`, `RenderMenuOptions`.
|
|
79
|
+
|
|
80
|
+
### ACP Rendering
|
|
81
|
+
|
|
82
|
+
- `acp`: namespace containing `renderAgentMessage`, `renderToolStart`, `renderToolComplete`, `renderReasoning`, `renderUsage`, `renderError`, `getAcpWriter`, and `withAcpWriter`.
|
|
83
|
+
- Namespace type: `AcpLineWriter`.
|
|
84
|
+
|
|
85
|
+
### Advanced Utilities
|
|
86
|
+
|
|
87
|
+
- `getTheme`, `resolveThemeName`, `resetThemeCache`: theme resolution and cache control.
|
|
88
|
+
- `configureTheme`, `getThemeConfig`, `resetTheme`: brand and label configuration.
|
|
89
|
+
- `resolveOutputFormat`, `resetOutputFormatCache`, `withOutputFormat`: terminal, Markdown, or JSON output-format selection.
|
|
90
|
+
- Types: `ThemeEnv`, `OutputFormat`.
|
|
91
|
+
|
|
92
|
+
## Brand Theme
|
|
93
|
+
|
|
94
|
+
The default configuration is `{ brand: "purple", label: "Poe" }`. Configure the package before producing design-system output:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { configureTheme, getThemeConfig, resetTheme } from "toolcraft-design";
|
|
98
|
+
|
|
99
|
+
configureTheme({ brand: "blue", label: "Toolcraft" });
|
|
100
|
+
|
|
101
|
+
console.log(getThemeConfig());
|
|
102
|
+
// { brand: "blue", label: "Toolcraft" }
|
|
103
|
+
|
|
104
|
+
resetTheme();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`configureTheme` accepts either or both fields and merges them into the current configuration. It throws for an unknown brand. `getThemeConfig` returns a copy of the current configuration, and `resetTheme` restores the purple `Poe` defaults.
|
|
108
|
+
|
|
109
|
+
The built-in brands are:
|
|
110
|
+
|
|
111
|
+
- `purple`: `#a200ff`
|
|
112
|
+
- `blue`: `#2f6fed`
|
|
113
|
+
- `green`: `#1f9d57`
|
|
114
|
+
|
|
115
|
+
Register another brand by adding a `Brand` to the exported `brands` registry before selecting it:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { brands, configureTheme, type Brand } from "toolcraft-design";
|
|
119
|
+
|
|
120
|
+
const orange: Brand = {
|
|
121
|
+
name: "orange",
|
|
122
|
+
primary: "#f97316"
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
brands.orange = orange;
|
|
126
|
+
configureTheme({ brand: "orange", label: "My CLI" });
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The registry key and `Brand.name` should match. Brand primary colors are CSS-style hex strings used to build light and dark terminal palettes.
|
|
130
|
+
|
|
131
|
+
## Environment Variables
|
|
132
|
+
|
|
133
|
+
### Theme and Brand
|
|
134
|
+
|
|
135
|
+
- `POE_CODE_THEME`: forces the rendering mode when set to `light` or `dark`. It takes precedence over `POE_THEME` and automatic terminal theme detection.
|
|
136
|
+
- `POE_THEME`: legacy light/dark override used when `POE_CODE_THEME` is not set to a valid mode.
|
|
137
|
+
- `POE_BRAND`: debug-only built-in or registered brand override. An explicit `configureTheme({ brand })` call takes precedence. Unknown values are ignored.
|
|
138
|
+
- `APPLE_INTERFACE_STYLE`: automatic macOS theme hint used when no valid explicit light/dark override is present.
|
|
139
|
+
- `VSCODE_COLOR_THEME_KIND`: automatic VS Code theme hint used after the macOS hint.
|
|
140
|
+
- `COLORFGBG`: terminal foreground/background hint used after the macOS and VS Code hints. Rendering defaults to dark when no hint resolves a mode.
|
|
141
|
+
|
|
142
|
+
### Output and Color
|
|
143
|
+
|
|
144
|
+
- `OUTPUT_FORMAT`: selects `terminal`, `markdown`, or `json` output for components that use the output-format resolver. Invalid or missing values default to `terminal`.
|
|
145
|
+
- `FORCE_COLOR`: enables color when present and not `0`, taking precedence over `NO_COLOR`.
|
|
146
|
+
- `NO_COLOR`: disables color when `FORCE_COLOR` does not enable it.
|
|
147
|
+
- `TERM`: participates in color support detection; an unset or `dumb` terminal disables color unless forced.
|
|
148
|
+
- `POE_NO_SPINNER`: uses non-animated spinner behavior when set to `1`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ThemePalette } from "../tokens/colors.js";
|
|
2
|
+
export type CatalogTone = "accent" | "muted" | "success" | "warning" | "error" | "info";
|
|
3
|
+
export interface CatalogMetric {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string | number;
|
|
6
|
+
tone?: CatalogTone;
|
|
7
|
+
}
|
|
8
|
+
export interface CatalogItem {
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
detail?: string;
|
|
12
|
+
tone?: CatalogTone;
|
|
13
|
+
}
|
|
14
|
+
export interface CatalogGroup {
|
|
15
|
+
title: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
items: CatalogItem[];
|
|
18
|
+
}
|
|
19
|
+
export interface RenderCatalogOptions {
|
|
20
|
+
theme: ThemePalette;
|
|
21
|
+
title: string;
|
|
22
|
+
subtitle?: string;
|
|
23
|
+
metrics?: CatalogMetric[];
|
|
24
|
+
groups: CatalogGroup[];
|
|
25
|
+
}
|
|
26
|
+
export declare function renderCatalog(options: RenderCatalogOptions): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { resolveOutputFormat } from "../internal/output-format.js";
|
|
2
|
+
import { stripAnsi } from "../internal/strip-ansi.js";
|
|
3
|
+
function applyTone(theme, value, tone) {
|
|
4
|
+
return tone === undefined ? value : theme[tone](value);
|
|
5
|
+
}
|
|
6
|
+
function renderMetrics(metrics, theme) {
|
|
7
|
+
return metrics
|
|
8
|
+
.map((metric) => applyTone(theme, `${metric.value} ${metric.label}`, metric.tone))
|
|
9
|
+
.join(theme.muted(" · "));
|
|
10
|
+
}
|
|
11
|
+
function renderTerminal(options) {
|
|
12
|
+
const title = [
|
|
13
|
+
options.theme.header(options.title),
|
|
14
|
+
options.subtitle === undefined ? undefined : options.theme.muted(options.subtitle)
|
|
15
|
+
]
|
|
16
|
+
.filter((value) => value !== undefined)
|
|
17
|
+
.join(" ");
|
|
18
|
+
const blocks = [
|
|
19
|
+
[title, options.metrics?.length ? renderMetrics(options.metrics, options.theme) : undefined]
|
|
20
|
+
.filter((value) => value !== undefined)
|
|
21
|
+
.join("\n")
|
|
22
|
+
];
|
|
23
|
+
for (const group of options.groups) {
|
|
24
|
+
const labelWidth = Math.max(...group.items.map((item) => item.label.length), 0);
|
|
25
|
+
const valueWidth = Math.max(...group.items.map((item) => item.value.length), 0);
|
|
26
|
+
const lines = [
|
|
27
|
+
`${options.theme.header(group.title)} ${options.theme.muted(String(group.items.length))}`,
|
|
28
|
+
...(group.description === undefined ? [] : [options.theme.muted(group.description)]),
|
|
29
|
+
...group.items.map((item) => {
|
|
30
|
+
const identity = `${applyTone(options.theme, item.label.padEnd(labelWidth), item.tone)} ${item.value.padEnd(valueWidth)}`;
|
|
31
|
+
return item.detail === undefined
|
|
32
|
+
? identity.trimEnd()
|
|
33
|
+
: `${identity} ${options.theme.muted(item.detail)}`;
|
|
34
|
+
})
|
|
35
|
+
];
|
|
36
|
+
blocks.push(lines.join("\n"));
|
|
37
|
+
}
|
|
38
|
+
return blocks.join("\n\n");
|
|
39
|
+
}
|
|
40
|
+
function escapeMarkdown(value) {
|
|
41
|
+
return stripAnsi(value).replaceAll("`", "\\`");
|
|
42
|
+
}
|
|
43
|
+
function renderMarkdown(options) {
|
|
44
|
+
const blocks = [`# ${escapeMarkdown(options.title)}`];
|
|
45
|
+
if (options.subtitle !== undefined) {
|
|
46
|
+
blocks.push(escapeMarkdown(options.subtitle));
|
|
47
|
+
}
|
|
48
|
+
if (options.metrics?.length) {
|
|
49
|
+
blocks.push(`**${options.metrics.map((metric) => `${metric.value} ${metric.label}`).join(" · ")}**`);
|
|
50
|
+
}
|
|
51
|
+
for (const group of options.groups) {
|
|
52
|
+
const header = [`## ${escapeMarkdown(group.title)} (${group.items.length})`];
|
|
53
|
+
if (group.description !== undefined) {
|
|
54
|
+
header.push(escapeMarkdown(group.description));
|
|
55
|
+
}
|
|
56
|
+
const items = group.items.map((item) => {
|
|
57
|
+
const detail = item.detail === undefined ? "" : ` — ${escapeMarkdown(item.detail)}`;
|
|
58
|
+
return `- \`${escapeMarkdown(item.label)}\` \`${escapeMarkdown(item.value)}\`${detail}`;
|
|
59
|
+
});
|
|
60
|
+
blocks.push(`${header.join("\n\n")}\n\n${items.join("\n")}`);
|
|
61
|
+
}
|
|
62
|
+
return blocks.join("\n\n");
|
|
63
|
+
}
|
|
64
|
+
function renderJson(options) {
|
|
65
|
+
return JSON.stringify({
|
|
66
|
+
title: stripAnsi(options.title),
|
|
67
|
+
...(options.subtitle === undefined ? {} : { subtitle: stripAnsi(options.subtitle) }),
|
|
68
|
+
metrics: (options.metrics ?? []).map((metric) => ({
|
|
69
|
+
...metric,
|
|
70
|
+
label: stripAnsi(metric.label),
|
|
71
|
+
value: typeof metric.value === "string" ? stripAnsi(metric.value) : metric.value
|
|
72
|
+
})),
|
|
73
|
+
groups: options.groups.map((group) => ({
|
|
74
|
+
title: stripAnsi(group.title),
|
|
75
|
+
...(group.description === undefined ? {} : { description: stripAnsi(group.description) }),
|
|
76
|
+
items: group.items.map((item) => ({
|
|
77
|
+
...item,
|
|
78
|
+
label: stripAnsi(item.label),
|
|
79
|
+
value: stripAnsi(item.value),
|
|
80
|
+
...(item.detail === undefined ? {} : { detail: stripAnsi(item.detail) })
|
|
81
|
+
}))
|
|
82
|
+
}))
|
|
83
|
+
}, null, 2);
|
|
84
|
+
}
|
|
85
|
+
export function renderCatalog(options) {
|
|
86
|
+
switch (resolveOutputFormat()) {
|
|
87
|
+
case "markdown":
|
|
88
|
+
return renderMarkdown(options);
|
|
89
|
+
case "json":
|
|
90
|
+
return renderJson(options);
|
|
91
|
+
default:
|
|
92
|
+
return renderTerminal(options);
|
|
93
|
+
}
|
|
94
|
+
}
|
package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/index.d.ts
RENAMED
|
@@ -10,5 +10,7 @@ export { formatCommandNotFound } from "./command-errors.js";
|
|
|
10
10
|
export { formatCommandNotFoundPanel } from "./command-errors.js";
|
|
11
11
|
export { renderTable } from "./table.js";
|
|
12
12
|
export type { TableColumn, RenderTableOptions } from "./table.js";
|
|
13
|
+
export { renderCatalog } from "./catalog.js";
|
|
14
|
+
export type { CatalogGroup, CatalogItem, CatalogMetric, CatalogTone, RenderCatalogOptions } from "./catalog.js";
|
|
13
15
|
export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./template.js";
|
|
14
16
|
export type { RenderTemplateOptions, TemplateEscape } from "./template.js";
|
|
@@ -6,4 +6,5 @@ export { helpFormatter, formatColumns, formatCommand, formatUsage, formatOption,
|
|
|
6
6
|
export { formatCommandNotFound } from "./command-errors.js";
|
|
7
7
|
export { formatCommandNotFoundPanel } from "./command-errors.js";
|
|
8
8
|
export { renderTable } from "./table.js";
|
|
9
|
+
export { renderCatalog } from "./catalog.js";
|
|
9
10
|
export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./template.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getTheme } from "../../internal/theme-detect.js";
|
|
2
|
-
import { light } from "../../tokens/colors.js";
|
|
3
2
|
export function renderFooter(buffer, rect, hints) {
|
|
4
3
|
buffer.clearRect(rect);
|
|
5
4
|
if (rect.width <= 0 || rect.height <= 0 || hints.length === 0) {
|
|
@@ -53,5 +52,5 @@ function truncateCells(cells, width) {
|
|
|
53
52
|
];
|
|
54
53
|
}
|
|
55
54
|
function getAccentStyle() {
|
|
56
|
-
return getTheme()
|
|
55
|
+
return getTheme().styles.accent;
|
|
57
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getTheme } from "../../internal/theme-detect.js";
|
|
2
2
|
import { hasAnsi, parseAnsi } from "../ansi.js";
|
|
3
3
|
import { displayWidth, expandTabs, graphemes, graphemeWidth } from "../terminal-width.js";
|
|
4
4
|
const TEXT_OFFSET = 3;
|
|
@@ -49,12 +49,11 @@ export function computeVisualLines(items, width) {
|
|
|
49
49
|
if (width <= 0) {
|
|
50
50
|
return [];
|
|
51
51
|
}
|
|
52
|
-
const
|
|
53
|
-
const mutedStyle = getMutedStyle(themeName);
|
|
52
|
+
const mutedStyle = getTheme().styles.muted;
|
|
54
53
|
const textWidth = Math.max(width - TEXT_OFFSET, 0);
|
|
55
54
|
const visualLines = [];
|
|
56
55
|
for (const item of items) {
|
|
57
|
-
const itemStyle = getItemStyle(item.kind
|
|
56
|
+
const itemStyle = getItemStyle(item.kind);
|
|
58
57
|
if (hasAnsi(item.text) || hasCursorControls(item.text)) {
|
|
59
58
|
const styledLines = parseAnsi(item.text, hasAnsi(item.text) ? {} : itemStyle);
|
|
60
59
|
let firstRow = true;
|
|
@@ -117,12 +116,12 @@ function appendSegment(segments, text, style) {
|
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
function stylesEqual(left, right) {
|
|
120
|
-
return left.fg === right.fg
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
return (left.fg === right.fg &&
|
|
120
|
+
left.bg === right.bg &&
|
|
121
|
+
left.bold === right.bold &&
|
|
122
|
+
left.dim === right.dim &&
|
|
123
|
+
left.inverse === right.inverse &&
|
|
124
|
+
left.underline === right.underline);
|
|
126
125
|
}
|
|
127
126
|
function getPrefix(kind) {
|
|
128
127
|
if (kind === "success") {
|
|
@@ -139,23 +138,21 @@ function getPrefix(kind) {
|
|
|
139
138
|
}
|
|
140
139
|
return "◇";
|
|
141
140
|
}
|
|
142
|
-
function getItemStyle(kind
|
|
141
|
+
function getItemStyle(kind) {
|
|
142
|
+
const styles = getTheme().styles;
|
|
143
143
|
if (kind === "success") {
|
|
144
|
-
return
|
|
144
|
+
return styles.success;
|
|
145
145
|
}
|
|
146
146
|
if (kind === "error") {
|
|
147
|
-
return
|
|
147
|
+
return styles.error;
|
|
148
148
|
}
|
|
149
149
|
if (kind === "tool") {
|
|
150
|
-
return
|
|
150
|
+
return styles.muted;
|
|
151
151
|
}
|
|
152
152
|
if (kind === "status") {
|
|
153
|
-
return
|
|
153
|
+
return styles.info;
|
|
154
154
|
}
|
|
155
|
-
return
|
|
156
|
-
}
|
|
157
|
-
function getMutedStyle(themeName) {
|
|
158
|
-
return themeName === "light" ? { fg: "#666666" } : { dim: true };
|
|
155
|
+
return styles.info;
|
|
159
156
|
}
|
|
160
157
|
function wrapText(value, width) {
|
|
161
158
|
const logicalLines = splitLogicalLines(value);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getTheme } from "../../internal/theme-detect.js";
|
|
2
|
-
import { light } from "../../tokens/colors.js";
|
|
3
2
|
export function renderStatsPane(buffer, rect, stats) {
|
|
4
3
|
buffer.clearRect(rect);
|
|
5
4
|
if (rect.width <= 0 || rect.height <= 0) {
|
|
@@ -104,18 +103,5 @@ function getStatusStyle(status) {
|
|
|
104
103
|
return getToneStyle("muted");
|
|
105
104
|
}
|
|
106
105
|
function getToneStyle(tone) {
|
|
107
|
-
|
|
108
|
-
if (tone === "muted") {
|
|
109
|
-
return isLightTheme ? { fg: "#666666" } : { dim: true };
|
|
110
|
-
}
|
|
111
|
-
if (tone === "info") {
|
|
112
|
-
return isLightTheme ? { fg: "#a200ff" } : { fg: "magenta" };
|
|
113
|
-
}
|
|
114
|
-
if (tone === "warning") {
|
|
115
|
-
return isLightTheme ? { fg: "#cc6600" } : { fg: "yellow" };
|
|
116
|
-
}
|
|
117
|
-
if (tone === "error") {
|
|
118
|
-
return isLightTheme ? { fg: "#cc0000" } : { fg: "red" };
|
|
119
|
-
}
|
|
120
|
-
return isLightTheme ? { fg: "#008800" } : { fg: "green" };
|
|
106
|
+
return getTheme().styles[tone];
|
|
121
107
|
}
|
|
@@ -117,14 +117,14 @@ const reviewComments = {
|
|
|
117
117
|
{
|
|
118
118
|
id: "pr-1847-comment-1",
|
|
119
119
|
title: "Review: detail loading",
|
|
120
|
-
subtitle: "packages/design
|
|
120
|
+
subtitle: "packages/toolcraft-design/src/explorer/jobs.ts:19",
|
|
121
121
|
body: "The 150 ms loading threshold is the right behavior. This demo should make that visible with --slow-detail.",
|
|
122
122
|
tone: "success"
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
125
|
id: "pr-1847-comment-2",
|
|
126
126
|
title: "Review: destructive confirm",
|
|
127
|
-
subtitle: "packages/design
|
|
127
|
+
subtitle: "packages/toolcraft-design/src/explorer/reducer.ts:435",
|
|
128
128
|
body: "Confirm modal behavior should be reachable from manual QA with a simple keybinding.",
|
|
129
129
|
tone: "warning"
|
|
130
130
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getTheme } from "../internal/theme-detect.js";
|
|
2
|
+
export function getExplorerTheme() {
|
|
3
|
+
const theme = getTheme();
|
|
4
|
+
return {
|
|
5
|
+
accent: theme.accent,
|
|
6
|
+
muted: theme.muted,
|
|
7
|
+
border: theme.muted,
|
|
8
|
+
borderFocused: theme.accent,
|
|
9
|
+
badge: (text, tone) => theme[tone](` ${text} `),
|
|
10
|
+
matchHighlight: (text) => theme.accent(`\u001b[4m${text}\u001b[24m`)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function getExplorerStyles() {
|
|
14
|
+
const styles = getTheme().styles;
|
|
15
|
+
return {
|
|
16
|
+
accent: styles.accent,
|
|
17
|
+
muted: styles.muted,
|
|
18
|
+
border: styles.muted,
|
|
19
|
+
borderFocused: styles.accent,
|
|
20
|
+
matchHighlight: { ...styles.accent, underline: true },
|
|
21
|
+
tones: {
|
|
22
|
+
success: styles.success,
|
|
23
|
+
warning: styles.warning,
|
|
24
|
+
error: styles.error,
|
|
25
|
+
info: styles.info,
|
|
26
|
+
muted: styles.muted
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * as tokens from "./tokens/index.js";
|
|
2
2
|
export { brand, dark, light } from "./tokens/colors.js";
|
|
3
|
+
export { brands } from "./tokens/brand.js";
|
|
4
|
+
export type { Brand } from "./tokens/brand.js";
|
|
3
5
|
export type { ThemeName, ThemePalette } from "./tokens/colors.js";
|
|
4
6
|
export { spacing } from "./tokens/spacing.js";
|
|
5
7
|
export { typography } from "./tokens/typography.js";
|
|
@@ -17,6 +19,8 @@ export { formatCommandNotFound } from "./components/command-errors.js";
|
|
|
17
19
|
export { formatCommandNotFoundPanel } from "./components/command-errors.js";
|
|
18
20
|
export { renderTable } from "./components/table.js";
|
|
19
21
|
export type { TableColumn, RenderTableOptions } from "./components/table.js";
|
|
22
|
+
export { renderCatalog } from "./components/catalog.js";
|
|
23
|
+
export type { CatalogGroup, CatalogItem, CatalogMetric, CatalogTone, RenderCatalogOptions } from "./components/catalog.js";
|
|
20
24
|
export { renderDetailCard } from "./components/detail-card.js";
|
|
21
25
|
export type { DetailCardRow, DetailCardSection, RenderDetailCardOptions } from "./components/detail-card.js";
|
|
22
26
|
export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./components/template.js";
|
|
@@ -28,7 +32,7 @@ export { createDashboard, shouldUseInteractiveDashboard } from "./dashboard/inde
|
|
|
28
32
|
export type { Dashboard, DashboardOptions } from "./dashboard/index.js";
|
|
29
33
|
export * as explorer from "./explorer/index.js";
|
|
30
34
|
export { runExplorer, singleDetail } from "./explorer/index.js";
|
|
31
|
-
export type { Row, DetailItem, Detail, DetailCtx, Action, ActionContext, ExplorerConfig, ReorderContext, Tone
|
|
35
|
+
export type { Row, DetailItem, Detail, DetailCtx, Action, ActionContext, ExplorerConfig, ReorderContext, Tone } from "./explorer/index.js";
|
|
32
36
|
export * as prompts from "./prompts/index.js";
|
|
33
37
|
export { intro, introPlain, outro, note, select, multiselect, text as promptText, confirm, confirmOrCancel, password, spinner, withSpinner, isCancel, cancel, log, PromptCancelledError } from "./prompts/index.js";
|
|
34
38
|
export type { SelectOptions, MultiselectOptions, TextOptions, ConfirmOptions, PasswordOptions, SpinnerOptions, WithSpinnerOptions } from "./prompts/index.js";
|
|
@@ -40,5 +44,7 @@ export { parse, render, renderMarkdown } from "./terminal-markdown/index.js";
|
|
|
40
44
|
export type { MdNode, RenderOptions } from "./terminal-markdown/index.js";
|
|
41
45
|
export { getTheme, resolveThemeName, resetThemeCache } from "./internal/theme-detect.js";
|
|
42
46
|
export type { ThemeEnv } from "./internal/theme-detect.js";
|
|
47
|
+
export { configureTheme, getThemeConfig, resetTheme } from "./internal/theme-state.js";
|
|
48
|
+
export { stripAnsi } from "./internal/strip-ansi.js";
|
|
43
49
|
export { resolveOutputFormat, resetOutputFormatCache, withOutputFormat } from "./internal/output-format.js";
|
|
44
50
|
export type { OutputFormat } from "./internal/output-format.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Tokens
|
|
2
2
|
export * as tokens from "./tokens/index.js";
|
|
3
3
|
export { brand, dark, light } from "./tokens/colors.js";
|
|
4
|
+
export { brands } from "./tokens/brand.js";
|
|
4
5
|
export { spacing } from "./tokens/spacing.js";
|
|
5
6
|
export { typography } from "./tokens/typography.js";
|
|
6
7
|
export { widths } from "./tokens/widths.js";
|
|
@@ -14,6 +15,7 @@ export * as helpFormatterPlain from "./components/help-formatter-plain.js";
|
|
|
14
15
|
export { formatCommandNotFound } from "./components/command-errors.js";
|
|
15
16
|
export { formatCommandNotFoundPanel } from "./components/command-errors.js";
|
|
16
17
|
export { renderTable } from "./components/table.js";
|
|
18
|
+
export { renderCatalog } from "./components/catalog.js";
|
|
17
19
|
export { renderDetailCard } from "./components/detail-card.js";
|
|
18
20
|
export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./components/template.js";
|
|
19
21
|
export { openExternal } from "./components/browser.js";
|
|
@@ -36,4 +38,6 @@ export { SPINNER_FRAMES, renderSpinnerFrame, renderSpinnerStopped, renderMenu }
|
|
|
36
38
|
export { parse, render, renderMarkdown } from "./terminal-markdown/index.js";
|
|
37
39
|
// Internal utilities (for advanced use)
|
|
38
40
|
export { getTheme, resolveThemeName, resetThemeCache } from "./internal/theme-detect.js";
|
|
41
|
+
export { configureTheme, getThemeConfig, resetTheme } from "./internal/theme-state.js";
|
|
42
|
+
export { stripAnsi } from "./internal/strip-ansi.js";
|
|
39
43
|
export { resolveOutputFormat, resetOutputFormatCache, withOutputFormat } from "./internal/output-format.js";
|
package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/theme-detect.js
RENAMED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getThemeConfig, getThemeRevision, isThemeBrandConfigured } from "./theme-state.js";
|
|
2
|
+
import { brands } from "../tokens/brand.js";
|
|
3
|
+
import { createPalette, dark, light } from "../tokens/colors.js";
|
|
2
4
|
function detectThemeFromEnv(env) {
|
|
3
5
|
const apple = env.APPLE_INTERFACE_STYLE;
|
|
4
6
|
if (typeof apple === "string") {
|
|
@@ -35,15 +37,35 @@ export function resolveThemeName(env = process.env) {
|
|
|
35
37
|
}
|
|
36
38
|
return "dark";
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
const themeCache = new Map();
|
|
41
|
+
let cachedRevision = -1;
|
|
39
42
|
export function getTheme(env) {
|
|
43
|
+
const themeName = resolveThemeName(env);
|
|
44
|
+
const config = getThemeConfig();
|
|
45
|
+
const requestedBrand = env?.POE_BRAND?.toLowerCase();
|
|
46
|
+
const activeBrandName = !isThemeBrandConfigured() && requestedBrand && Object.hasOwn(brands, requestedBrand)
|
|
47
|
+
? requestedBrand
|
|
48
|
+
: config.brand;
|
|
49
|
+
const revision = getThemeRevision();
|
|
50
|
+
if (revision !== cachedRevision) {
|
|
51
|
+
themeCache.clear();
|
|
52
|
+
cachedRevision = revision;
|
|
53
|
+
}
|
|
54
|
+
const cacheKey = `${activeBrandName}:${themeName}`;
|
|
55
|
+
const cachedTheme = themeCache.get(cacheKey);
|
|
40
56
|
if (cachedTheme) {
|
|
41
57
|
return cachedTheme;
|
|
42
58
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
const activeBrand = brands[activeBrandName];
|
|
60
|
+
const theme = activeBrandName === "purple"
|
|
61
|
+
? themeName === "light"
|
|
62
|
+
? light
|
|
63
|
+
: dark
|
|
64
|
+
: createPalette(activeBrand, themeName);
|
|
65
|
+
themeCache.set(cacheKey, theme);
|
|
66
|
+
return theme;
|
|
46
67
|
}
|
|
47
68
|
export function resetThemeCache() {
|
|
48
|
-
|
|
69
|
+
themeCache.clear();
|
|
70
|
+
cachedRevision = getThemeRevision();
|
|
49
71
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ThemeConfig {
|
|
2
|
+
brand: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function configureTheme(patch: {
|
|
6
|
+
brand?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
}): void;
|
|
9
|
+
export declare function getThemeConfig(): ThemeConfig;
|
|
10
|
+
export declare function getThemeRevision(): number;
|
|
11
|
+
export declare function isThemeBrandConfigured(): boolean;
|
|
12
|
+
export declare function resetTheme(): void;
|