@niujiajie/freespec 0.0.0-stage → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +58 -2
- package/bin/freespec.js +5 -0
- package/dist/cli/index.d.ts +25 -0
- package/dist/cli/index.js +359 -0
- package/dist/commands/shared-output.d.ts +18 -0
- package/dist/commands/shared-output.js +61 -0
- package/dist/commands/workflow/default-schema.d.ts +2 -0
- package/dist/commands/workflow/default-schema.js +4 -0
- package/dist/commands/workflow/index.d.ts +13 -0
- package/dist/commands/workflow/index.js +10 -0
- package/dist/commands/workflow/instructions.d.ts +39 -0
- package/dist/commands/workflow/instructions.js +565 -0
- package/dist/commands/workflow/new-change.d.ts +19 -0
- package/dist/commands/workflow/new-change.js +135 -0
- package/dist/commands/workflow/shared.d.ts +94 -0
- package/dist/commands/workflow/shared.js +169 -0
- package/dist/commands/workflow/status.d.ts +18 -0
- package/dist/commands/workflow/status.js +201 -0
- package/dist/core/artifact-graph/graph.d.ts +72 -0
- package/dist/core/artifact-graph/graph.js +165 -0
- package/dist/core/artifact-graph/index.d.ts +9 -0
- package/dist/core/artifact-graph/index.js +14 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +208 -0
- package/dist/core/artifact-graph/instruction-loader.js +268 -0
- package/dist/core/artifact-graph/outputs.d.ts +19 -0
- package/dist/core/artifact-graph/outputs.js +351 -0
- package/dist/core/artifact-graph/resolver.d.ts +89 -0
- package/dist/core/artifact-graph/resolver.js +342 -0
- package/dist/core/artifact-graph/schema.d.ts +27 -0
- package/dist/core/artifact-graph/schema.js +160 -0
- package/dist/core/artifact-graph/state.d.ts +12 -0
- package/dist/core/artifact-graph/state.js +31 -0
- package/dist/core/artifact-graph/types.d.ts +40 -0
- package/dist/core/artifact-graph/types.js +59 -0
- package/dist/core/available-tools.d.ts +18 -0
- package/dist/core/available-tools.js +49 -0
- package/dist/core/change-layout.d.ts +17 -0
- package/dist/core/change-layout.js +30 -0
- package/dist/core/change-metadata/index.d.ts +2 -0
- package/dist/core/change-metadata/index.js +2 -0
- package/dist/core/change-metadata/schema.d.ts +23 -0
- package/dist/core/change-metadata/schema.js +46 -0
- package/dist/core/change-status-policy.d.ts +49 -0
- package/dist/core/change-status-policy.js +50 -0
- package/dist/core/command-generation/adapters/amazon-q.d.ts +17 -0
- package/dist/core/command-generation/adapters/amazon-q.js +32 -0
- package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
- package/dist/core/command-generation/adapters/antigravity.js +27 -0
- package/dist/core/command-generation/adapters/atomcode.d.ts +24 -0
- package/dist/core/command-generation/adapters/atomcode.js +46 -0
- package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
- package/dist/core/command-generation/adapters/auggie.js +28 -0
- package/dist/core/command-generation/adapters/bob.d.ts +18 -0
- package/dist/core/command-generation/adapters/bob.js +33 -0
- package/dist/core/command-generation/adapters/claude.d.ts +13 -0
- package/dist/core/command-generation/adapters/claude.js +32 -0
- package/dist/core/command-generation/adapters/cline.d.ts +14 -0
- package/dist/core/command-generation/adapters/cline.js +27 -0
- package/dist/core/command-generation/adapters/codeassistant.d.ts +15 -0
- package/dist/core/command-generation/adapters/codeassistant.js +29 -0
- package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
- package/dist/core/command-generation/adapters/codebuddy.js +29 -0
- package/dist/core/command-generation/adapters/codestudio.d.ts +13 -0
- package/dist/core/command-generation/adapters/codestudio.js +27 -0
- package/dist/core/command-generation/adapters/command-code.d.ts +19 -0
- package/dist/core/command-generation/adapters/command-code.js +34 -0
- package/dist/core/command-generation/adapters/continue.d.ts +13 -0
- package/dist/core/command-generation/adapters/continue.js +33 -0
- package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
- package/dist/core/command-generation/adapters/costrict.js +28 -0
- package/dist/core/command-generation/adapters/crush.d.ts +13 -0
- package/dist/core/command-generation/adapters/crush.js +30 -0
- package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
- package/dist/core/command-generation/adapters/cursor.js +31 -0
- package/dist/core/command-generation/adapters/devin.d.ts +19 -0
- package/dist/core/command-generation/adapters/devin.js +36 -0
- package/dist/core/command-generation/adapters/easycode.d.ts +17 -0
- package/dist/core/command-generation/adapters/easycode.js +28 -0
- package/dist/core/command-generation/adapters/factory.d.ts +13 -0
- package/dist/core/command-generation/adapters/factory.js +28 -0
- package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
- package/dist/core/command-generation/adapters/gemini.js +27 -0
- package/dist/core/command-generation/adapters/gigacode.d.ts +17 -0
- package/dist/core/command-generation/adapters/gigacode.js +31 -0
- package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
- package/dist/core/command-generation/adapters/github-copilot.js +27 -0
- package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
- package/dist/core/command-generation/adapters/iflow.js +30 -0
- package/dist/core/command-generation/adapters/index.d.ts +40 -0
- package/dist/core/command-generation/adapters/index.js +40 -0
- package/dist/core/command-generation/adapters/junie.d.ts +13 -0
- package/dist/core/command-generation/adapters/junie.js +27 -0
- package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
- package/dist/core/command-generation/adapters/kilocode.js +23 -0
- package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
- package/dist/core/command-generation/adapters/kiro.js +27 -0
- package/dist/core/command-generation/adapters/lingma.d.ts +13 -0
- package/dist/core/command-generation/adapters/lingma.js +30 -0
- package/dist/core/command-generation/adapters/oh-my-pi.d.ts +21 -0
- package/dist/core/command-generation/adapters/oh-my-pi.js +42 -0
- package/dist/core/command-generation/adapters/opencode.d.ts +14 -0
- package/dist/core/command-generation/adapters/opencode.js +38 -0
- package/dist/core/command-generation/adapters/pi.d.ts +18 -0
- package/dist/core/command-generation/adapters/pi.js +39 -0
- package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
- package/dist/core/command-generation/adapters/qoder.js +30 -0
- package/dist/core/command-generation/adapters/qwen.d.ts +17 -0
- package/dist/core/command-generation/adapters/qwen.js +31 -0
- package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
- package/dist/core/command-generation/adapters/roocode.js +27 -0
- package/dist/core/command-generation/adapters/trae.d.ts +13 -0
- package/dist/core/command-generation/adapters/trae.js +28 -0
- package/dist/core/command-generation/adapters/zcode.d.ts +16 -0
- package/dist/core/command-generation/adapters/zcode.js +33 -0
- package/dist/core/command-generation/generator.d.ts +29 -0
- package/dist/core/command-generation/generator.js +43 -0
- package/dist/core/command-generation/index.d.ts +22 -0
- package/dist/core/command-generation/index.js +24 -0
- package/dist/core/command-generation/invocation.d.ts +73 -0
- package/dist/core/command-generation/invocation.js +77 -0
- package/dist/core/command-generation/registry.d.ts +36 -0
- package/dist/core/command-generation/registry.js +114 -0
- package/dist/core/command-generation/toml.d.ts +19 -0
- package/dist/core/command-generation/toml.js +39 -0
- package/dist/core/command-generation/types.d.ts +63 -0
- package/dist/core/command-generation/types.js +8 -0
- package/dist/core/command-generation/yaml.d.ts +36 -0
- package/dist/core/command-generation/yaml.js +48 -0
- package/dist/core/command-surface.d.ts +15 -0
- package/dist/core/command-surface.js +33 -0
- package/dist/core/config-prompts.d.ts +9 -0
- package/dist/core/config-prompts.js +56 -0
- package/dist/core/config-schema.d.ts +98 -0
- package/dist/core/config-schema.js +308 -0
- package/dist/core/config.d.ts +50 -0
- package/dist/core/config.js +122 -0
- package/dist/core/file-state.d.ts +36 -0
- package/dist/core/file-state.js +144 -0
- package/dist/core/file-view.d.ts +13 -0
- package/dist/core/file-view.js +14 -0
- package/dist/core/global-config.d.ts +101 -0
- package/dist/core/global-config.js +182 -0
- package/dist/core/id.d.ts +17 -0
- package/dist/core/id.js +30 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +7 -0
- package/dist/core/init.d.ts +57 -0
- package/dist/core/init.js +836 -0
- package/dist/core/list.d.ts +11 -0
- package/dist/core/list.js +197 -0
- package/dist/core/migration.d.ts +121 -0
- package/dist/core/migration.js +540 -0
- package/dist/core/onboarding-commands.d.ts +30 -0
- package/dist/core/onboarding-commands.js +38 -0
- package/dist/core/openspec-root.d.ts +47 -0
- package/dist/core/openspec-root.js +196 -0
- package/dist/core/planning-home.d.ts +16 -0
- package/dist/core/planning-home.js +67 -0
- package/dist/core/profile-sync-drift.d.ts +31 -0
- package/dist/core/profile-sync-drift.js +201 -0
- package/dist/core/profiles.d.ts +19 -0
- package/dist/core/profiles.js +33 -0
- package/dist/core/project-config.d.ts +132 -0
- package/dist/core/project-config.js +519 -0
- package/dist/core/references.d.ts +10 -0
- package/dist/core/references.js +46 -0
- package/dist/core/root-selection.d.ts +59 -0
- package/dist/core/root-selection.js +132 -0
- package/dist/core/shared/allowed-tools.d.ts +12 -0
- package/dist/core/shared/allowed-tools.js +12 -0
- package/dist/core/shared/ide-restart.d.ts +26 -0
- package/dist/core/shared/ide-restart.js +42 -0
- package/dist/core/shared/index.d.ts +11 -0
- package/dist/core/shared/index.js +11 -0
- package/dist/core/shared/skill-content-equivalence.d.ts +7 -0
- package/dist/core/shared/skill-content-equivalence.js +45 -0
- package/dist/core/shared/skill-files.d.ts +7 -0
- package/dist/core/shared/skill-files.js +43 -0
- package/dist/core/shared/skill-generation.d.ts +49 -0
- package/dist/core/shared/skill-generation.js +125 -0
- package/dist/core/shared/skill-paths.d.ts +13 -0
- package/dist/core/shared/skill-paths.js +23 -0
- package/dist/core/shared/tool-detection.d.ts +99 -0
- package/dist/core/shared/tool-detection.js +318 -0
- package/dist/core/shared-skill-target.d.ts +51 -0
- package/dist/core/shared-skill-target.js +239 -0
- package/dist/core/store/errors.d.ts +20 -0
- package/dist/core/store/errors.js +22 -0
- package/dist/core/store/index.d.ts +2 -0
- package/dist/core/store/index.js +2 -0
- package/dist/core/styles/palette.d.ts +7 -0
- package/dist/core/styles/palette.js +8 -0
- package/dist/core/templates/optional-workflow.d.ts +69 -0
- package/dist/core/templates/optional-workflow.js +140 -0
- package/dist/core/templates/types.d.ts +19 -0
- package/dist/core/templates/types.js +5 -0
- package/dist/core/templates/workflows/personal.d.ts +22 -0
- package/dist/core/templates/workflows/personal.js +225 -0
- package/dist/core/update-plan.d.ts +127 -0
- package/dist/core/update-plan.js +390 -0
- package/dist/core/update.d.ts +154 -0
- package/dist/core/update.js +723 -0
- package/dist/core/version-check.d.ts +188 -0
- package/dist/core/version-check.js +906 -0
- package/dist/core/zod-issues.d.ts +4 -0
- package/dist/core/zod-issues.js +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/prompts/searchable-multi-select.d.ts +35 -0
- package/dist/prompts/searchable-multi-select.js +188 -0
- package/dist/telemetry/config.d.ts +37 -0
- package/dist/telemetry/config.js +148 -0
- package/dist/telemetry/index.d.ts +39 -0
- package/dist/telemetry/index.js +217 -0
- package/dist/telemetry/opt-out.d.ts +17 -0
- package/dist/telemetry/opt-out.js +27 -0
- package/dist/ui/ascii-patterns.d.ts +16 -0
- package/dist/ui/ascii-patterns.js +133 -0
- package/dist/ui/welcome-screen.d.ts +18 -0
- package/dist/ui/welcome-screen.js +199 -0
- package/dist/utils/change-metadata.d.ts +116 -0
- package/dist/utils/change-metadata.js +324 -0
- package/dist/utils/change-utils.d.ts +79 -0
- package/dist/utils/change-utils.js +121 -0
- package/dist/utils/ci.d.ts +12 -0
- package/dist/utils/ci.js +16 -0
- package/dist/utils/command-references.d.ts +104 -0
- package/dist/utils/command-references.js +190 -0
- package/dist/utils/date.d.ts +8 -0
- package/dist/utils/date.js +13 -0
- package/dist/utils/executable-path.d.ts +5 -0
- package/dist/utils/executable-path.js +44 -0
- package/dist/utils/file-system.d.ts +58 -0
- package/dist/utils/file-system.js +432 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/interactive.d.ts +85 -0
- package/dist/utils/interactive.js +174 -0
- package/dist/utils/item-discovery.d.ts +15 -0
- package/dist/utils/item-discovery.js +33 -0
- package/dist/utils/line-endings.d.ts +34 -0
- package/dist/utils/line-endings.js +46 -0
- package/dist/utils/match.d.ts +3 -0
- package/dist/utils/match.js +22 -0
- package/dist/utils/nested-change.d.ts +35 -0
- package/dist/utils/nested-change.js +185 -0
- package/dist/utils/shell-detection.d.ts +20 -0
- package/dist/utils/shell-detection.js +94 -0
- package/dist/utils/task-progress.d.ts +67 -0
- package/dist/utils/task-progress.js +184 -0
- package/package.json +74 -4
- package/schemas//351/273/230/350/256/244/schema.yaml +68 -0
- package/schemas//351/273/230/350/256/244/templates//344/273/273/345/212/241/346/270/205/345/215/225.md +25 -0
- package/schemas//351/273/230/350/256/244/templates//346/265/213/350/257/225/347/224/250/344/276/213.md +34 -0
- package/schemas//351/273/230/350/256/244/templates//350/256/276/350/256/241/346/226/207/346/241/243.md +172 -0
- package/schemas//351/273/230/350/256/244/templates//351/234/200/346/261/202/346/226/207/346/241/243.md +19 -0
- package/skill-files//344/273/273/345/212/241/references//346/212/244/346/240/217.md +43 -0
- package/skill-files//344/273/273/345/212/241/references//347/262/222/345/272/246.md +23 -0
- package/skill-files//344/273/273/345/212/241/references//347/272/246/346/235/237.md +8 -0
- package/skill-files//344/273/273/345/212/241/scripts/check-tasks.mjs +83 -0
- package/skill-files//345/206/231Java/references/Java/350/247/204/350/214/203.md +25 -0
- package/skill-files//345/206/231Java/references//345/215/261/351/231/251/345/206/231/346/263/225.md +27 -0
- package/skill-files//345/206/231Java/references//345/256/214/346/210/220/345/257/271/347/205/247.md +15 -0
- package/skill-files//345/206/231Java/references//346/212/244/346/240/217.md +35 -0
- package/skill-files//345/206/231Java/references//347/272/246/346/235/237.md +8 -0
- package/skill-files//345/206/231Java/references//350/270/251/345/235/221.md +17 -0
- package/skill-files//345/256/241Java/references//346/212/244/346/240/217.md +19 -0
- package/skill-files//345/256/241Java/references//347/244/272/344/276/213.md +23 -0
- package/skill-files//345/256/241Java/references//347/272/246/346/235/237.md +7 -0
- package/skill-files//345/256/241Java/references//350/247/204/345/210/231.md +23 -0
- package/skill-files//345/256/241Java/references//351/242/206/345/237/237/346/243/200/351/241/271.md +58 -0
- package/skill-files//345/256/241/346/226/207/346/241/243/references//346/212/244/346/240/217.md +18 -0
- package/skill-files//345/256/241/346/226/207/346/241/243/references//347/272/246/346/235/237.md +8 -0
- package/skill-files//345/256/241/346/226/207/346/241/243/references//347/273/264/345/272/246.md +17 -0
- package/skill-files//345/256/241/346/226/207/346/241/243/references//350/270/251/345/235/221.md +11 -0
- package/skill-files//346/226/260/345/273/272/references//344/272/244/346/216/245.md +11 -0
- package/skill-files//346/226/260/345/273/272/references//346/212/244/346/240/217.md +14 -0
- package/skill-files//346/226/260/345/273/272/references//347/272/246/346/235/237.md +7 -0
- package/skill-files//346/267/261/346/200/235/config/prompts.yaml +114 -0
- package/skill-files//346/267/261/346/200/235/references//344/270/211/346/226/271/346/240/270/345/257/271.md +72 -0
- package/skill-files//346/267/261/346/200/235/references//344/276/213/345/255/220.md +39 -0
- package/skill-files//346/267/261/346/200/235/references//346/200/216/344/271/210/346/203/263.md +61 -0
- package/skill-files//346/267/261/346/200/235/references//346/212/244/346/240/217.md +26 -0
- package/skill-files//346/267/261/346/200/235/references//347/202/271/351/200/211/346/217/220/351/227/256.md +66 -0
- package/skill-files//346/267/261/346/200/235/references//347/231/273/350/256/260.md +45 -0
- package/skill-files//346/267/261/346/200/235/references//347/272/246/346/235/237.md +9 -0
- package/skill-files//347/224/250/344/276/213/references//346/200/216/344/271/210/345/206/231.md +13 -0
- package/skill-files//347/224/250/344/276/213/references//346/212/244/346/240/217.md +42 -0
- package/skill-files//347/224/250/344/276/213/references//347/272/246/346/235/237.md +5 -0
- package/skill-files//347/224/250/344/276/213/scripts/check-cases.mjs +70 -0
- package/skill-files//350/256/276/350/256/241/references//345/207/206/345/244/207.md +25 -0
- package/skill-files//350/256/276/350/256/241/references//346/212/244/346/240/217.md +134 -0
- package/skill-files//350/256/276/350/256/241/references//346/226/207/351/243/216.md +17 -0
- package/skill-files//350/256/276/350/256/241/references//347/225/214/351/235/242.md +18 -0
- package/skill-files//350/256/276/350/256/241/references//347/261/273/345/236/213.md +19 -0
- package/skill-files//350/256/276/350/256/241/references//347/272/246/346/235/237.md +25 -0
- package/skill-files//350/256/276/350/256/241/scripts/_smoke.mjs +72 -0
- package/skill-files//350/256/276/350/256/241/scripts/check-design.mjs +331 -0
- package/skill-files//351/234/200/346/261/202/references//346/212/244/346/240/217.md +26 -0
- package/skill-files//351/234/200/346/261/202/references//346/226/207/351/243/216.md +23 -0
- package/skill-files//351/234/200/346/261/202/references//346/267/261/346/200/235/346/221/204/345/205/245.md +21 -0
- package/skill-files//351/234/200/346/261/202/references//347/272/246/346/235/237.md +8 -0
- package/skill-files//351/234/200/346/261/202/references//351/234/200/346/261/202/345/276/205/345/256/232.md +13 -0
- package/skill-files//351/234/200/346/261/202/scripts/check-requirements.mjs +60 -0
- package/skill-files//351/252/214/346/224/266/references//346/212/244/346/240/217.md +27 -0
- package/skill-files//351/252/214/346/224/266/references//346/240/270/345/257/271.md +17 -0
- package/skill-files//351/252/214/346/224/266/references//347/272/246/346/235/237.md +7 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
// Constants
|
|
5
|
+
export const GLOBAL_CONFIG_DIR_NAME = 'freespec';
|
|
6
|
+
export const GLOBAL_CONFIG_FILE_NAME = 'config.json';
|
|
7
|
+
export const GLOBAL_DATA_DIR_NAME = 'freespec';
|
|
8
|
+
const DEFAULT_CONFIG = {
|
|
9
|
+
featureFlags: {},
|
|
10
|
+
profile: 'core',
|
|
11
|
+
delivery: 'both',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Gets the global configuration directory path following XDG Base Directory Specification.
|
|
15
|
+
*
|
|
16
|
+
* - All platforms: $XDG_CONFIG_HOME/freespec/ if XDG_CONFIG_HOME is set
|
|
17
|
+
* - Unix/macOS fallback: ~/.config/freespec/
|
|
18
|
+
* - Windows fallback: %APPDATA%/freespec/
|
|
19
|
+
*/
|
|
20
|
+
export function getGlobalConfigDir() {
|
|
21
|
+
// XDG_CONFIG_HOME takes precedence on all platforms when explicitly set
|
|
22
|
+
const xdgConfigHome = process.env.XDG_CONFIG_HOME;
|
|
23
|
+
if (xdgConfigHome) {
|
|
24
|
+
return path.join(xdgConfigHome, GLOBAL_CONFIG_DIR_NAME);
|
|
25
|
+
}
|
|
26
|
+
const platform = os.platform();
|
|
27
|
+
if (platform === 'win32') {
|
|
28
|
+
// Windows: use %APPDATA%
|
|
29
|
+
const appData = process.env.APPDATA;
|
|
30
|
+
if (appData) {
|
|
31
|
+
return path.join(appData, GLOBAL_CONFIG_DIR_NAME);
|
|
32
|
+
}
|
|
33
|
+
// Fallback for Windows if APPDATA is not set
|
|
34
|
+
return path.join(os.homedir(), 'AppData', 'Roaming', GLOBAL_CONFIG_DIR_NAME);
|
|
35
|
+
}
|
|
36
|
+
// Unix/macOS fallback: ~/.config
|
|
37
|
+
return path.join(os.homedir(), '.config', GLOBAL_CONFIG_DIR_NAME);
|
|
38
|
+
}
|
|
39
|
+
function joinGlobalDataPath(platform, ...segments) {
|
|
40
|
+
return platform === 'win32'
|
|
41
|
+
? path.win32.join(...segments)
|
|
42
|
+
: path.posix.join(...segments);
|
|
43
|
+
}
|
|
44
|
+
export function getGlobalDataDir(options = {}) {
|
|
45
|
+
const env = options.env ?? process.env;
|
|
46
|
+
const platform = options.platform ?? os.platform();
|
|
47
|
+
// XDG_DATA_HOME takes precedence on all platforms when explicitly set
|
|
48
|
+
const xdgDataHome = env.XDG_DATA_HOME;
|
|
49
|
+
if (xdgDataHome) {
|
|
50
|
+
return joinGlobalDataPath(platform, xdgDataHome, GLOBAL_DATA_DIR_NAME);
|
|
51
|
+
}
|
|
52
|
+
const homedir = options.homedir ?? os.homedir();
|
|
53
|
+
if (platform === 'win32') {
|
|
54
|
+
// Windows: use %LOCALAPPDATA%
|
|
55
|
+
const localAppData = env.LOCALAPPDATA;
|
|
56
|
+
if (localAppData) {
|
|
57
|
+
return joinGlobalDataPath(platform, localAppData, GLOBAL_DATA_DIR_NAME);
|
|
58
|
+
}
|
|
59
|
+
// Fallback for Windows if LOCALAPPDATA is not set
|
|
60
|
+
return joinGlobalDataPath(platform, homedir, 'AppData', 'Local', GLOBAL_DATA_DIR_NAME);
|
|
61
|
+
}
|
|
62
|
+
// Unix/macOS fallback: ~/.local/share
|
|
63
|
+
return joinGlobalDataPath(platform, homedir, '.local', 'share', GLOBAL_DATA_DIR_NAME);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Gets the path to the global config file.
|
|
67
|
+
*/
|
|
68
|
+
export function getGlobalConfigPath() {
|
|
69
|
+
return path.join(getGlobalConfigDir(), GLOBAL_CONFIG_FILE_NAME);
|
|
70
|
+
}
|
|
71
|
+
// Config paths already warned about. One command reads the config several
|
|
72
|
+
// times (telemetry, the update check, the command itself); warn once.
|
|
73
|
+
const warnedInvalidJsonPaths = new Set();
|
|
74
|
+
/**
|
|
75
|
+
* Loads the global configuration from disk.
|
|
76
|
+
* Returns default configuration if file doesn't exist or is invalid.
|
|
77
|
+
* Merges loaded config with defaults to ensure new fields are available.
|
|
78
|
+
*/
|
|
79
|
+
export function getGlobalConfig() {
|
|
80
|
+
const configPath = getGlobalConfigPath();
|
|
81
|
+
try {
|
|
82
|
+
if (!fs.existsSync(configPath)) {
|
|
83
|
+
return { ...DEFAULT_CONFIG };
|
|
84
|
+
}
|
|
85
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
86
|
+
const parsed = JSON.parse(content);
|
|
87
|
+
// A root that is not a plain object carries no settings, and spreading it
|
|
88
|
+
// would leak its shape into the result: a string contributes numeric
|
|
89
|
+
// character keys. Answer with plain defaults, as for a file that did not
|
|
90
|
+
// parse at all. Same predicate the writers refuse to save over.
|
|
91
|
+
if (!isConfigRootObject(parsed)) {
|
|
92
|
+
return { ...DEFAULT_CONFIG };
|
|
93
|
+
}
|
|
94
|
+
// Merge with defaults (loaded values take precedence)
|
|
95
|
+
const merged = {
|
|
96
|
+
...DEFAULT_CONFIG,
|
|
97
|
+
...parsed,
|
|
98
|
+
// Deep merge featureFlags
|
|
99
|
+
featureFlags: {
|
|
100
|
+
...DEFAULT_CONFIG.featureFlags,
|
|
101
|
+
...(parsed.featureFlags || {})
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
// Schema evolution: apply defaults for new fields if not present in loaded config
|
|
105
|
+
if (parsed.profile === undefined) {
|
|
106
|
+
merged.profile = DEFAULT_CONFIG.profile;
|
|
107
|
+
}
|
|
108
|
+
if (parsed.delivery === undefined) {
|
|
109
|
+
merged.delivery = DEFAULT_CONFIG.delivery;
|
|
110
|
+
}
|
|
111
|
+
return merged;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
// Log warning for parse errors, but not for missing files
|
|
115
|
+
if (error instanceof SyntaxError && !warnedInvalidJsonPaths.has(configPath)) {
|
|
116
|
+
warnedInvalidJsonPaths.add(configPath);
|
|
117
|
+
console.error(`Warning: Invalid JSON in ${configPath}, using defaults`);
|
|
118
|
+
}
|
|
119
|
+
return { ...DEFAULT_CONFIG };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether a parsed JSON root can serve as a global config object.
|
|
124
|
+
*
|
|
125
|
+
* Valid JSON that is not a plain object (`null`, an array, a string, a number,
|
|
126
|
+
* a boolean) still reads as defaults, so it is just as unsafe to save over as
|
|
127
|
+
* a file that did not parse at all. Every reader and writer of the global
|
|
128
|
+
* config shares this one predicate so they cannot drift apart.
|
|
129
|
+
*/
|
|
130
|
+
export function isConfigRootObject(parsed) {
|
|
131
|
+
return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The one-line, actionable refusal every global-config writer reports when it
|
|
135
|
+
* declines to overwrite a file it could not read.
|
|
136
|
+
*/
|
|
137
|
+
export function unreadableGlobalConfigMessage(configPath) {
|
|
138
|
+
return (`Refusing to overwrite ${configPath}: it could not be parsed, so saving would replace every setting in it. ` +
|
|
139
|
+
'Fix it with "freespec config edit", or reset it with "freespec config reset --all".');
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Whether the global config file exists but cannot be read or parsed.
|
|
143
|
+
*
|
|
144
|
+
* getGlobalConfig() answers with defaults for such a file so that reads keep
|
|
145
|
+
* working, but those defaults are not the user's settings: saving them back
|
|
146
|
+
* would erase everything the file holds, and the file may contain an opt-out
|
|
147
|
+
* such as `telemetry.enabled: false` that the defaults do not.
|
|
148
|
+
*/
|
|
149
|
+
export function isGlobalConfigUnreadable() {
|
|
150
|
+
const configPath = getGlobalConfigPath();
|
|
151
|
+
if (!fs.existsSync(configPath)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
return !isConfigRootObject(JSON.parse(fs.readFileSync(configPath, 'utf-8')));
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Saves the global configuration to disk.
|
|
163
|
+
* Creates the config directory if it doesn't exist. Refuses to overwrite an
|
|
164
|
+
* existing file it cannot parse unless `replaceUnreadable` is set.
|
|
165
|
+
*/
|
|
166
|
+
export function saveGlobalConfig(config, options = {}) {
|
|
167
|
+
const configDir = getGlobalConfigDir();
|
|
168
|
+
const configPath = getGlobalConfigPath();
|
|
169
|
+
if (!options.replaceUnreadable && isGlobalConfigUnreadable()) {
|
|
170
|
+
throw new Error(unreadableGlobalConfigMessage(configPath));
|
|
171
|
+
}
|
|
172
|
+
// Create directory if it doesn't exist
|
|
173
|
+
if (!fs.existsSync(configDir)) {
|
|
174
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
175
|
+
}
|
|
176
|
+
fs.writeFileSync(configPath, serializeGlobalConfig(config), 'utf-8');
|
|
177
|
+
}
|
|
178
|
+
/** The bytes `saveGlobalConfig` writes, for a caller that only plans the write. */
|
|
179
|
+
export function serializeGlobalConfig(config) {
|
|
180
|
+
return JSON.stringify(config, null, 2) + '\n';
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=global-config.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one kebab id grammar. Store ids, change ids, and legacy initiative ids
|
|
3
|
+
* all share it.
|
|
4
|
+
*/
|
|
5
|
+
export declare const KEBAB_ID_REGEX: RegExp;
|
|
6
|
+
export declare function isKebabId(value: string): boolean;
|
|
7
|
+
/** Human rendering of the grammar, shared so the wording never forks. */
|
|
8
|
+
export declare const KEBAB_ID_DESCRIPTION = "must be kebab-case with lowercase letters, numbers, and single hyphen separators";
|
|
9
|
+
/** The fix-line twin of KEBAB_ID_DESCRIPTION, shared for the same reason. */
|
|
10
|
+
export declare const KEBAB_ID_FIX = "Use kebab-case with lowercase letters, numbers, and single hyphen separators.";
|
|
11
|
+
/**
|
|
12
|
+
* The folder-safe-name grammar (store ids layer the kebab grammar on
|
|
13
|
+
* top of it; workset member labels use it alone). Returns a problem
|
|
14
|
+
* description, or null when valid.
|
|
15
|
+
*/
|
|
16
|
+
export declare function folderStyleNameProblem(value: string, label: string): string | null;
|
|
17
|
+
//# sourceMappingURL=id.d.ts.map
|
package/dist/core/id.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one kebab id grammar. Store ids, change ids, and legacy initiative ids
|
|
3
|
+
* all share it.
|
|
4
|
+
*/
|
|
5
|
+
export const KEBAB_ID_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
6
|
+
export function isKebabId(value) {
|
|
7
|
+
return KEBAB_ID_REGEX.test(value);
|
|
8
|
+
}
|
|
9
|
+
/** Human rendering of the grammar, shared so the wording never forks. */
|
|
10
|
+
export const KEBAB_ID_DESCRIPTION = 'must be kebab-case with lowercase letters, numbers, and single hyphen separators';
|
|
11
|
+
/** The fix-line twin of KEBAB_ID_DESCRIPTION, shared for the same reason. */
|
|
12
|
+
export const KEBAB_ID_FIX = 'Use kebab-case with lowercase letters, numbers, and single hyphen separators.';
|
|
13
|
+
/**
|
|
14
|
+
* The folder-safe-name grammar (store ids layer the kebab grammar on
|
|
15
|
+
* top of it; workset member labels use it alone). Returns a problem
|
|
16
|
+
* description, or null when valid.
|
|
17
|
+
*/
|
|
18
|
+
export function folderStyleNameProblem(value, label) {
|
|
19
|
+
if (value.length === 0) {
|
|
20
|
+
return `${label} must not be empty`;
|
|
21
|
+
}
|
|
22
|
+
if (value === '.' || value === '..') {
|
|
23
|
+
return `${label} must not be '${value}'`;
|
|
24
|
+
}
|
|
25
|
+
if (/[\\/]/u.test(value)) {
|
|
26
|
+
return `${label} must not contain path separators`;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=id.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { GLOBAL_CONFIG_DIR_NAME, GLOBAL_CONFIG_FILE_NAME, GLOBAL_DATA_DIR_NAME, type GlobalDataDirOptions, type GlobalConfig, getGlobalConfigDir, getGlobalConfigPath, getGlobalConfig, saveGlobalConfig, getGlobalDataDir } from './global-config.js';
|
|
2
|
+
export * from './references.js';
|
|
3
|
+
export * from './store/index.js';
|
|
4
|
+
export * from './planning-home.js';
|
|
5
|
+
export * from './openspec-root.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Core FreeSpec logic will be implemented here
|
|
2
|
+
export { GLOBAL_CONFIG_DIR_NAME, GLOBAL_CONFIG_FILE_NAME, GLOBAL_DATA_DIR_NAME, getGlobalConfigDir, getGlobalConfigPath, getGlobalConfig, saveGlobalConfig, getGlobalDataDir } from './global-config.js';
|
|
3
|
+
export * from './references.js';
|
|
4
|
+
export * from './store/index.js';
|
|
5
|
+
export * from './planning-home.js';
|
|
6
|
+
export * from './openspec-root.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Init Command
|
|
3
|
+
*
|
|
4
|
+
* Sets up FreeSpec with Agent Skills and /freespec:* slash commands.
|
|
5
|
+
* This is the unified setup command that replaces both the old init and experimental commands.
|
|
6
|
+
*/
|
|
7
|
+
type InitCommandOptions = {
|
|
8
|
+
tools?: string;
|
|
9
|
+
language?: string;
|
|
10
|
+
force?: boolean;
|
|
11
|
+
interactive?: boolean;
|
|
12
|
+
profile?: string;
|
|
13
|
+
/** Commander's --no-animation flag: false disables the welcome animation. */
|
|
14
|
+
animation?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare class InitCommand {
|
|
17
|
+
private readonly toolsArg?;
|
|
18
|
+
private readonly language?;
|
|
19
|
+
private readonly force;
|
|
20
|
+
private readonly interactiveOption?;
|
|
21
|
+
private readonly profileOverride?;
|
|
22
|
+
private readonly animation;
|
|
23
|
+
constructor(options?: InitCommandOptions);
|
|
24
|
+
execute(targetPath: string): Promise<void>;
|
|
25
|
+
private validate;
|
|
26
|
+
private canPromptInteractively;
|
|
27
|
+
private resolveProfileOverride;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the workflows the effective profile installs, so onboarding output
|
|
30
|
+
* only mentions commands that will actually exist.
|
|
31
|
+
*/
|
|
32
|
+
private getActiveWorkflows;
|
|
33
|
+
private getSelectedTools;
|
|
34
|
+
private resolveToolsArg;
|
|
35
|
+
private validateTools;
|
|
36
|
+
private createDirectoryStructure;
|
|
37
|
+
private writeGitkeepFiles;
|
|
38
|
+
/**
|
|
39
|
+
* Generates skill files and slash commands for each selected tool,
|
|
40
|
+
* honoring the configured delivery mode (skills, commands, or both).
|
|
41
|
+
*
|
|
42
|
+
* @param projectPath - Absolute path to the project root
|
|
43
|
+
* @param tools - Selected tools with their skill directory metadata
|
|
44
|
+
* @returns Created, refreshed, and failed tools plus removed artifact counts
|
|
45
|
+
*/
|
|
46
|
+
private generateSkillsAndCommands;
|
|
47
|
+
private normalizeLanguage;
|
|
48
|
+
private languageContext;
|
|
49
|
+
private assertLanguageCanBeApplied;
|
|
50
|
+
private createConfig;
|
|
51
|
+
private displaySuccessMessage;
|
|
52
|
+
private startSpinner;
|
|
53
|
+
private removeSkillDirs;
|
|
54
|
+
private removeCommandFiles;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=init.d.ts.map
|