@codewalla_india/openspec 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -22
- package/README.md +272 -191
- package/bin/openspec.js +5 -5
- package/dist/cli/index.js +99 -62
- package/dist/commands/change.d.ts +0 -2
- package/dist/commands/change.js +107 -86
- package/dist/commands/config.js +14 -16
- package/dist/commands/doctor.js +9 -4
- package/dist/commands/feedback.js +79 -30
- package/dist/commands/modify.d.ts +26 -0
- package/dist/commands/modify.js +147 -0
- package/dist/commands/schema.js +170 -91
- package/dist/commands/show.js +5 -2
- package/dist/commands/spec.js +49 -29
- package/dist/commands/store.js +15 -21
- package/dist/commands/validate.d.ts +8 -0
- package/dist/commands/validate.js +43 -20
- package/dist/commands/workflow/index.d.ts +2 -2
- package/dist/commands/workflow/index.js +1 -1
- package/dist/commands/workflow/instructions.d.ts +6 -26
- package/dist/commands/workflow/instructions.js +183 -376
- package/dist/commands/workflow/new-change.d.ts +0 -4
- package/dist/commands/workflow/new-change.js +10 -28
- package/dist/commands/workflow/shared.d.ts +34 -19
- package/dist/commands/workflow/shared.js +34 -4
- package/dist/commands/workflow/status.js +10 -32
- package/dist/commands/workflow/templates.js +15 -5
- package/dist/commands/workset.d.ts +2 -2
- package/dist/commands/workset.js +19 -22
- package/dist/comprehension-quiz/fingerprint.d.ts +39 -0
- package/dist/comprehension-quiz/fingerprint.js +84 -0
- package/dist/comprehension-quiz/index.d.ts +42 -0
- package/dist/comprehension-quiz/index.js +47 -0
- package/dist/comprehension-quiz/pass-record.d.ts +44 -0
- package/dist/comprehension-quiz/pass-record.js +98 -0
- package/dist/comprehension-quiz/providers/anthropic.d.ts +34 -0
- package/dist/comprehension-quiz/providers/anthropic.js +53 -0
- package/dist/comprehension-quiz/providers/factory.d.ts +44 -0
- package/dist/comprehension-quiz/providers/factory.js +174 -0
- package/dist/comprehension-quiz/providers/interface.d.ts +59 -0
- package/dist/comprehension-quiz/providers/interface.js +63 -0
- package/dist/comprehension-quiz/providers/local.d.ts +34 -0
- package/dist/comprehension-quiz/providers/local.js +53 -0
- package/dist/comprehension-quiz/providers/ollama.d.ts +34 -0
- package/dist/comprehension-quiz/providers/ollama.js +53 -0
- package/dist/comprehension-quiz/providers/openai.d.ts +34 -0
- package/dist/comprehension-quiz/providers/openai.js +53 -0
- package/dist/comprehension-quiz/question-generator.d.ts +69 -0
- package/dist/comprehension-quiz/question-generator.js +141 -0
- package/dist/comprehension-quiz/quiz-executor.d.ts +70 -0
- package/dist/comprehension-quiz/quiz-executor.js +165 -0
- package/dist/comprehension-quiz/types.d.ts +115 -0
- package/dist/comprehension-quiz/types.js +11 -0
- package/dist/core/archive.d.ts +14 -1
- package/dist/core/archive.js +1350 -190
- package/dist/core/artifact-graph/graph.d.ts +28 -9
- package/dist/core/artifact-graph/graph.js +94 -43
- package/dist/core/artifact-graph/index.d.ts +1 -1
- package/dist/core/artifact-graph/index.js +1 -1
- package/dist/core/artifact-graph/instruction-loader.d.ts +30 -3
- package/dist/core/artifact-graph/instruction-loader.js +70 -12
- package/dist/core/artifact-graph/outputs.d.ts +1 -0
- package/dist/core/artifact-graph/outputs.js +67 -5
- package/dist/core/artifact-graph/resolver.d.ts +14 -0
- package/dist/core/artifact-graph/resolver.js +69 -15
- package/dist/core/artifact-graph/types.js +21 -3
- package/dist/core/available-tools.d.ts +2 -2
- package/dist/core/available-tools.js +14 -3
- package/dist/core/change-metadata/schema.d.ts +2 -0
- package/dist/core/change-metadata/schema.js +13 -0
- package/dist/core/change-status-policy.d.ts +10 -1
- package/dist/core/change-status-policy.js +30 -2
- package/dist/core/command-generation/adapters/amazon-q.d.ts +4 -0
- package/dist/core/command-generation/adapters/amazon-q.js +11 -5
- package/dist/core/command-generation/adapters/antigravity.js +6 -5
- package/dist/core/command-generation/adapters/auggie.js +7 -6
- package/dist/core/command-generation/adapters/bob.d.ts +5 -1
- package/dist/core/command-generation/adapters/bob.js +11 -10
- package/dist/core/command-generation/adapters/claude.d.ts +1 -1
- package/dist/core/command-generation/adapters/claude.js +12 -17
- package/dist/core/command-generation/adapters/cline.js +5 -5
- package/dist/core/command-generation/adapters/codebuddy.js +8 -7
- package/dist/core/command-generation/adapters/continue.js +8 -7
- package/dist/core/command-generation/adapters/costrict.js +7 -6
- package/dist/core/command-generation/adapters/crush.js +9 -9
- package/dist/core/command-generation/adapters/cursor.js +8 -8
- 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/factory.js +7 -6
- package/dist/core/command-generation/adapters/gemini.js +40 -5
- package/dist/core/command-generation/adapters/github-copilot.js +6 -5
- package/dist/core/command-generation/adapters/iflow.js +9 -8
- package/dist/core/command-generation/adapters/index.d.ts +4 -2
- package/dist/core/command-generation/adapters/index.js +4 -2
- package/dist/core/command-generation/adapters/junie.js +6 -5
- package/dist/core/command-generation/adapters/kilocode.js +1 -1
- package/dist/core/command-generation/adapters/kiro.js +6 -5
- package/dist/core/command-generation/adapters/lingma.js +9 -9
- 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.js +6 -8
- package/dist/core/command-generation/adapters/pi.d.ts +2 -2
- package/dist/core/command-generation/adapters/pi.js +7 -10
- package/dist/core/command-generation/adapters/qoder.js +9 -9
- package/dist/core/command-generation/adapters/qwen.d.ts +7 -3
- package/dist/core/command-generation/adapters/qwen.js +14 -9
- package/dist/core/command-generation/adapters/roocode.d.ts +4 -4
- package/dist/core/command-generation/adapters/roocode.js +9 -9
- 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 +8 -0
- package/dist/core/command-generation/generator.js +15 -1
- package/dist/core/command-generation/index.d.ts +1 -1
- package/dist/core/command-generation/index.js +1 -1
- 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.js +8 -4
- package/dist/core/command-generation/types.d.ts +9 -2
- package/dist/core/command-generation/yaml.d.ts +20 -6
- package/dist/core/command-generation/yaml.js +31 -21
- package/dist/core/command-surface.d.ts +15 -0
- package/dist/core/command-surface.js +33 -0
- package/dist/core/completions/command-registry.js +16 -61
- package/dist/core/completions/generators/bash-generator.js +41 -41
- package/dist/core/completions/generators/fish-generator.js +7 -7
- package/dist/core/completions/generators/powershell-generator.js +44 -37
- package/dist/core/completions/generators/zsh-generator.js +33 -33
- package/dist/core/completions/installers/zsh-installer.d.ts +9 -0
- package/dist/core/completions/installers/zsh-installer.js +20 -4
- package/dist/core/completions/templates/bash-templates.js +24 -24
- package/dist/core/completions/templates/fish-templates.js +38 -38
- package/dist/core/completions/templates/powershell-templates.js +28 -28
- package/dist/core/completions/templates/zsh-templates.js +39 -39
- package/dist/core/config-prompts.d.ts +1 -1
- package/dist/core/config-prompts.js +14 -1
- package/dist/core/config-schema.d.ts +10 -1
- package/dist/core/config-schema.js +67 -1
- package/dist/core/config.d.ts +15 -0
- package/dist/core/config.js +46 -5
- package/dist/core/file-state.js +56 -24
- package/dist/core/github-copilot/cloud-agent.d.ts +95 -0
- package/dist/core/github-copilot/cloud-agent.js +497 -0
- package/dist/core/global-config.d.ts +16 -0
- package/dist/core/init.d.ts +58 -0
- package/dist/core/init.js +474 -73
- package/dist/core/legacy-cleanup.d.ts +59 -0
- package/dist/core/legacy-cleanup.js +253 -24
- package/dist/core/list.js +23 -16
- package/dist/core/migration.d.ts +73 -1
- package/dist/core/migration.js +360 -11
- package/dist/core/modify/conflict-detector.d.ts +26 -0
- package/dist/core/modify/conflict-detector.js +62 -0
- package/dist/core/modify/dependency-propagator.d.ts +38 -0
- package/dist/core/modify/dependency-propagator.js +103 -0
- package/dist/core/modify/history-tracker.d.ts +34 -0
- package/dist/core/modify/history-tracker.js +114 -0
- package/dist/core/modify/index.d.ts +7 -0
- package/dist/core/modify/index.js +7 -0
- package/dist/core/onboarding-commands.d.ts +30 -0
- package/dist/core/onboarding-commands.js +38 -0
- package/dist/core/openspec-root.js +18 -15
- package/dist/core/parsers/change-parser.d.ts +17 -2
- package/dist/core/parsers/change-parser.js +35 -21
- package/dist/core/parsers/code-fence.d.ts +15 -0
- package/dist/core/parsers/code-fence.js +49 -0
- package/dist/core/parsers/markdown-parser.d.ts +0 -3
- package/dist/core/parsers/markdown-parser.js +7 -60
- package/dist/core/parsers/requirement-blocks.d.ts +29 -0
- package/dist/core/parsers/requirement-blocks.js +150 -31
- package/dist/core/parsers/requirement-text.d.ts +48 -0
- package/dist/core/parsers/requirement-text.js +98 -0
- package/dist/core/parsers/spec-structure.d.ts +1 -1
- package/dist/core/parsers/spec-structure.js +20 -30
- package/dist/core/profile-sync-drift.d.ts +0 -8
- package/dist/core/profile-sync-drift.js +49 -50
- package/dist/core/profiles.d.ts +2 -2
- package/dist/core/profiles.js +2 -2
- package/dist/core/project-config.d.ts +27 -18
- package/dist/core/project-config.js +101 -34
- package/dist/core/references.js +42 -4
- package/dist/core/relationship-health.d.ts +8 -0
- package/dist/core/relationship-health.js +13 -0
- package/dist/core/root-selection.d.ts +9 -6
- package/dist/core/root-selection.js +42 -5
- package/dist/core/schemas/base.schema.js +7 -2
- package/dist/core/shared/allowed-tools.d.ts +12 -0
- package/dist/core/shared/allowed-tools.js +12 -0
- package/dist/core/shared/index.d.ts +1 -0
- package/dist/core/shared/index.js +1 -0
- package/dist/core/shared/skill-content-equivalence.d.ts +7 -0
- package/dist/core/shared/skill-content-equivalence.js +41 -0
- package/dist/core/shared/skill-generation.js +17 -13
- 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 +27 -7
- package/dist/core/shared/tool-detection.js +167 -37
- package/dist/core/shared-skill-target.d.ts +16 -0
- package/dist/core/shared-skill-target.js +156 -0
- package/dist/core/specs-apply.d.ts +80 -33
- package/dist/core/specs-apply.js +667 -145
- package/dist/core/store/git.d.ts +13 -0
- package/dist/core/store/git.js +24 -0
- package/dist/core/store/operations.js +20 -0
- package/dist/core/templates/skill-templates.d.ts +3 -2
- package/dist/core/templates/skill-templates.js +3 -2
- package/dist/core/templates/workflows/apply-change.d.ts +10 -0
- package/dist/core/templates/workflows/apply-change.js +186 -224
- package/dist/core/templates/workflows/archive-change.js +387 -260
- package/dist/core/templates/workflows/bulk-archive-change.js +655 -475
- package/dist/core/templates/workflows/continue-change.js +210 -219
- package/dist/core/templates/workflows/explore.js +479 -443
- package/dist/core/templates/workflows/feedback.js +97 -97
- package/dist/core/templates/workflows/ff-change.js +200 -191
- package/dist/core/templates/workflows/modify-change.d.ts +4 -1
- package/dist/core/templates/workflows/modify-change.js +237 -115
- package/dist/core/templates/workflows/new-change.js +127 -134
- package/dist/core/templates/workflows/onboard.js +548 -542
- package/dist/core/templates/workflows/propose.js +273 -217
- package/dist/core/templates/workflows/store-selection.d.ts +1 -1
- package/dist/core/templates/workflows/store-selection.js +1 -1
- package/dist/core/templates/workflows/sync-specs.js +500 -273
- package/dist/core/templates/workflows/update-change.d.ts +10 -0
- package/dist/core/templates/workflows/update-change.js +177 -0
- package/dist/core/templates/workflows/verify-change.js +324 -326
- package/dist/core/update.d.ts +40 -5
- package/dist/core/update.js +411 -96
- package/dist/core/validation/constants.d.ts +4 -1
- package/dist/core/validation/constants.js +4 -1
- package/dist/core/validation/plan-validator.d.ts +8 -0
- package/dist/core/validation/plan-validator.js +45 -0
- package/dist/core/validation/task-numbering.d.ts +16 -0
- package/dist/core/validation/task-numbering.js +57 -0
- package/dist/core/validation/validator.d.ts +27 -3
- package/dist/core/validation/validator.js +337 -48
- package/dist/core/version-check.d.ts +152 -0
- package/dist/core/version-check.js +731 -0
- package/dist/core/view.js +13 -18
- package/dist/prompts/searchable-multi-select.js +1 -1
- package/dist/telemetry/caller-detection.d.ts +27 -0
- package/dist/telemetry/caller-detection.js +85 -0
- package/dist/telemetry/caller-detection.test.d.ts +5 -0
- package/dist/telemetry/config.d.ts +48 -2
- package/dist/telemetry/config.js +113 -11
- package/dist/telemetry/config.test.d.ts +5 -0
- package/dist/telemetry/deduplication.d.ts +35 -0
- package/dist/telemetry/deduplication.js +82 -0
- package/dist/telemetry/deduplication.test.d.ts +5 -0
- package/dist/telemetry/identity.d.ts +62 -22
- package/dist/telemetry/identity.js +147 -102
- package/dist/telemetry/index.d.ts +126 -15
- package/dist/telemetry/index.js +569 -37
- package/dist/telemetry/sanitization.d.ts +40 -0
- package/dist/telemetry/sanitization.js +114 -0
- package/dist/telemetry/sanitization.test.d.ts +5 -0
- package/dist/telemetry/throttling.d.ts +20 -0
- package/dist/telemetry/throttling.js +70 -0
- package/dist/ui/welcome-screen.d.ts +9 -1
- package/dist/ui/welcome-screen.js +91 -38
- package/dist/utils/change-metadata.d.ts +43 -0
- package/dist/utils/change-metadata.js +123 -7
- package/dist/utils/change-utils.d.ts +10 -4
- package/dist/utils/change-utils.js +20 -13
- package/dist/utils/ci.d.ts +12 -0
- package/dist/utils/ci.js +16 -0
- package/dist/utils/command-references.d.ts +92 -6
- package/dist/utils/command-references.js +180 -7
- package/dist/utils/date.d.ts +8 -0
- package/dist/utils/date.js +13 -0
- package/dist/utils/file-system.d.ts +10 -0
- package/dist/utils/file-system.js +70 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/interactive.d.ts +23 -0
- package/dist/utils/interactive.js +32 -0
- package/dist/utils/item-discovery.d.ts +19 -0
- package/dist/utils/item-discovery.js +30 -48
- package/dist/utils/shell-detection.d.ts +1 -1
- package/dist/utils/shell-detection.js +64 -11
- package/dist/utils/spec-discovery.d.ts +40 -0
- package/dist/utils/spec-discovery.js +115 -0
- package/dist/utils/task-progress.d.ts +29 -1
- package/dist/utils/task-progress.js +109 -15
- package/package.json +96 -84
- package/schemas/spec-driven/schema.yaml +252 -184
- package/schemas/spec-driven/templates/design.md +19 -19
- package/schemas/spec-driven/templates/plan-template.md +91 -0
- package/schemas/spec-driven/templates/proposal.md +29 -24
- package/schemas/spec-driven/templates/spec.md +11 -8
- package/schemas/spec-driven/templates/tasks.md +9 -9
- package/scripts/postinstall.js +83 -83
- package/dist/core/command-generation/adapters/codex.d.ts +0 -16
- package/dist/core/command-generation/adapters/codex.js +0 -39
- package/dist/core/command-generation/adapters/windsurf.d.ts +0 -14
- package/dist/core/command-generation/adapters/windsurf.js +0 -38
- package/dist/core/comprehension/config.d.ts +0 -20
- package/dist/core/comprehension/config.js +0 -23
- package/dist/core/comprehension/fingerprint.d.ts +0 -14
- package/dist/core/comprehension/fingerprint.js +0 -33
- package/dist/core/comprehension/index.d.ts +0 -57
- package/dist/core/comprehension/index.js +0 -87
- package/dist/core/comprehension/pass-record.d.ts +0 -29
- package/dist/core/comprehension/pass-record.js +0 -64
- package/dist/core/comprehension/stats.d.ts +0 -35
- package/dist/core/comprehension/stats.js +0 -133
- package/dist/core/templates/workflows/comprehension-guidance.d.ts +0 -9
- package/dist/core/templates/workflows/comprehension-guidance.js +0 -73
- package/dist/core/templates/workflows/mcp-guidance.d.ts +0 -13
- package/dist/core/templates/workflows/mcp-guidance.js +0 -131
- package/dist/core/templates/workflows/user-prompt-guidance.d.ts +0 -16
- package/dist/core/templates/workflows/user-prompt-guidance.js +0 -48
- package/dist/telemetry/caller.d.ts +0 -5
- package/dist/telemetry/caller.js +0 -29
- package/dist/telemetry/client.d.ts +0 -27
- package/dist/telemetry/client.js +0 -127
- package/dist/telemetry/command-context.d.ts +0 -13
- package/dist/telemetry/command-context.js +0 -59
- package/dist/telemetry/comprehension.d.ts +0 -44
- package/dist/telemetry/comprehension.js +0 -105
- package/dist/telemetry/content.d.ts +0 -10
- package/dist/telemetry/content.js +0 -56
- package/dist/telemetry/git-stats.d.ts +0 -12
- package/dist/telemetry/git-stats.js +0 -69
- package/dist/telemetry/identify-cache.d.ts +0 -7
- package/dist/telemetry/identify-cache.js +0 -47
- package/dist/telemetry/input.d.ts +0 -17
- package/dist/telemetry/input.js +0 -68
- package/dist/telemetry/marker.d.ts +0 -37
- package/dist/telemetry/marker.js +0 -67
- package/dist/telemetry/workflow.d.ts +0 -85
- package/dist/telemetry/workflow.js +0 -318
- package/schemas/spec-driven/templates/plan.md +0 -19
|
@@ -1,125 +1,170 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Identity management for telemetry.
|
|
3
|
+
*
|
|
4
|
+
* Handles identity collection, storage, validation, and retrieval.
|
|
5
|
+
* Identity is stored securely in a separate file with restricted permissions.
|
|
4
6
|
*/
|
|
5
|
-
import { input } from '@inquirer/prompts';
|
|
6
7
|
import { promises as fs } from 'fs';
|
|
7
8
|
import path from 'path';
|
|
8
9
|
import { getGlobalConfigDir } from '../core/global-config.js';
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
`or create ${getIdentityFilePath()}.`);
|
|
10
|
+
// Constants
|
|
11
|
+
export const IDENTITY_FILE_NAME = 'telemetry-identity.json';
|
|
12
|
+
/**
|
|
13
|
+
* Get the path to the identity file.
|
|
14
|
+
* Follows platform-specific config directory conventions.
|
|
15
|
+
*
|
|
16
|
+
* - All platforms: $XDG_CONFIG_HOME/openspec/ if XDG_CONFIG_HOME is set
|
|
17
|
+
* - Unix/macOS fallback: ~/.config/openspec/
|
|
18
|
+
* - Windows fallback: %APPDATA%/openspec/
|
|
19
|
+
*/
|
|
20
|
+
export function getIdentityPath() {
|
|
21
|
+
const configDir = getGlobalConfigDir();
|
|
22
|
+
return path.join(configDir, IDENTITY_FILE_NAME);
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Read identity from file or environment variable.
|
|
26
|
+
* Environment variable takes precedence over file.
|
|
27
|
+
*
|
|
28
|
+
* @returns The identity string, or null if not configured
|
|
29
|
+
*/
|
|
30
|
+
export async function readIdentity() {
|
|
31
|
+
// Check environment variable first (highest priority)
|
|
32
|
+
const envIdentity = process.env.OPENSPEC_TELEMETRY_USER;
|
|
33
|
+
if (envIdentity) {
|
|
34
|
+
return envIdentity.trim();
|
|
31
35
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export function getIdentityFilePath() {
|
|
35
|
-
return path.join(getGlobalConfigDir(), IDENTITY_FILENAME);
|
|
36
|
-
}
|
|
37
|
-
export async function readStoredUserId() {
|
|
36
|
+
// Fall back to file
|
|
37
|
+
const identityPath = getIdentityPath();
|
|
38
38
|
try {
|
|
39
|
-
const content = await fs.readFile(
|
|
39
|
+
const content = await fs.readFile(identityPath, 'utf-8');
|
|
40
40
|
const parsed = JSON.parse(content);
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
return parsed.identity || null;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (error.code === 'ENOENT') {
|
|
45
|
+
return null;
|
|
43
46
|
}
|
|
47
|
+
// If parse fails or another read error occurs, return null
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Write identity to file with restricted permissions.
|
|
53
|
+
*
|
|
54
|
+
* @param identity - The identity string to write
|
|
55
|
+
*/
|
|
56
|
+
export async function writeIdentity(identity) {
|
|
57
|
+
const identityPath = getIdentityPath();
|
|
58
|
+
const identityDir = path.dirname(identityPath);
|
|
59
|
+
// Create directory if it doesn't exist
|
|
60
|
+
await fs.mkdir(identityDir, { recursive: true });
|
|
61
|
+
// Write identity file
|
|
62
|
+
await fs.writeFile(identityPath, JSON.stringify({ identity }, null, 2) + '\n');
|
|
63
|
+
// Set file permissions to 0600 (owner read/write only)
|
|
64
|
+
// This works on Unix-like systems; on Windows it's a no-op
|
|
65
|
+
try {
|
|
66
|
+
await fs.chmod(identityPath, 0o600);
|
|
44
67
|
}
|
|
45
68
|
catch {
|
|
46
|
-
//
|
|
69
|
+
// Windows doesn't support chmod in the same way, but that's okay
|
|
70
|
+
// The file is still protected by OS-level permissions
|
|
47
71
|
}
|
|
48
|
-
return null;
|
|
49
72
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Validate email format using RFC 5322 compliant pattern.
|
|
75
|
+
*
|
|
76
|
+
* @param email - The email string to validate
|
|
77
|
+
* @returns True if valid, false otherwise
|
|
78
|
+
*/
|
|
79
|
+
export function validateEmail(email) {
|
|
80
|
+
// Structural checks first
|
|
81
|
+
if (!email.includes('@'))
|
|
82
|
+
return false;
|
|
83
|
+
const parts = email.split('@');
|
|
84
|
+
if (parts.length !== 2)
|
|
85
|
+
return false;
|
|
86
|
+
if (parts[0].length === 0 || parts[1].length === 0)
|
|
87
|
+
return false;
|
|
88
|
+
// Domain must have at least one dot for a valid email format
|
|
89
|
+
if (!parts[1].includes('.'))
|
|
90
|
+
return false;
|
|
91
|
+
// RFC 5322 compliant email regex pattern
|
|
92
|
+
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
93
|
+
return emailRegex.test(email);
|
|
56
94
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (options?.prompt === true) {
|
|
72
|
-
try {
|
|
73
|
-
return await promptAndStoreTelemetryIdentity();
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
if (error instanceof TelemetryIdentityRequiredError) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
95
|
+
/**
|
|
96
|
+
* Validate username format.
|
|
97
|
+
* Username must be 3-32 characters, alphanumeric + underscores + hyphens.
|
|
98
|
+
*
|
|
99
|
+
* @param username - The username string to validate
|
|
100
|
+
* @returns True if valid, false otherwise
|
|
101
|
+
*/
|
|
102
|
+
export function validateUsername(username) {
|
|
103
|
+
const usernameRegex = /^[a-zA-Z0-9_-]{3,32}$/;
|
|
104
|
+
// Ensure @ is not allowed in usernames
|
|
105
|
+
if (username.includes('@'))
|
|
106
|
+
return false;
|
|
107
|
+
return usernameRegex.test(username);
|
|
83
108
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
console.log('Codewalla OpenSpec collects usage analytics tied to your email/username.');
|
|
93
|
-
const answer = await input({
|
|
94
|
-
message: 'Enter your Codewalla email or username:',
|
|
95
|
-
validate: validateUserId,
|
|
96
|
-
});
|
|
97
|
-
await writeStoredUserId(answer);
|
|
98
|
-
return answer.trim();
|
|
109
|
+
/**
|
|
110
|
+
* Normalize identity input by trimming whitespace and converting to lowercase.
|
|
111
|
+
*
|
|
112
|
+
* @param identity - The identity string to normalize
|
|
113
|
+
* @returns The normalized identity string
|
|
114
|
+
*/
|
|
115
|
+
export function normalizeIdentity(identity) {
|
|
116
|
+
return identity.trim().toLowerCase();
|
|
99
117
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Validate identity format (email or username).
|
|
120
|
+
*
|
|
121
|
+
* @param identity - The identity string to validate
|
|
122
|
+
* @returns Object with valid flag and error messages if invalid
|
|
123
|
+
*/
|
|
124
|
+
export function validateIdentity(identity) {
|
|
125
|
+
const errors = [];
|
|
126
|
+
if (!identity || identity.trim().length === 0) {
|
|
127
|
+
errors.push('Identity cannot be empty');
|
|
128
|
+
return { valid: false, errors };
|
|
104
129
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return existing;
|
|
130
|
+
const isEmail = validateEmail(identity);
|
|
131
|
+
const isUsername = validateUsername(identity);
|
|
132
|
+
// Must be either a valid email OR a valid username, not both
|
|
133
|
+
if (!isEmail && !isUsername) {
|
|
134
|
+
errors.push('Identity must be a valid email address or username (3-32 alphanumeric characters, underscores, or hyphens)');
|
|
111
135
|
}
|
|
112
|
-
|
|
113
|
-
|
|
136
|
+
// If it looks like an email (has @), ensure it's actually a valid email
|
|
137
|
+
if (identity.includes('@') && !isEmail) {
|
|
138
|
+
errors.push('Invalid email format');
|
|
114
139
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return
|
|
140
|
+
// If it doesn't have @ and is not a valid username, reject
|
|
141
|
+
if (!identity.includes('@') && !isUsername) {
|
|
142
|
+
errors.push('Invalid username format');
|
|
143
|
+
}
|
|
144
|
+
return { valid: errors.length === 0, errors };
|
|
120
145
|
}
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Interactive prompt for identity collection.
|
|
148
|
+
* Uses inquirer for consistent prompting with other OpenSpec commands.
|
|
149
|
+
*
|
|
150
|
+
* @returns The user's identity input
|
|
151
|
+
*/
|
|
152
|
+
export async function promptForIdentity() {
|
|
153
|
+
const { input } = await import('@inquirer/prompts');
|
|
154
|
+
const identity = await input({
|
|
155
|
+
message: 'Enter your identity for telemetry (email or username):',
|
|
156
|
+
validate: (value) => {
|
|
157
|
+
if (!value || value.trim().length === 0) {
|
|
158
|
+
return 'Identity cannot be empty';
|
|
159
|
+
}
|
|
160
|
+
const normalized = normalizeIdentity(value);
|
|
161
|
+
const validation = validateIdentity(normalized);
|
|
162
|
+
if (!validation.valid) {
|
|
163
|
+
return validation.errors[0];
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
return normalizeIdentity(identity);
|
|
124
169
|
}
|
|
125
170
|
//# sourceMappingURL=identity.js.map
|
|
@@ -1,17 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare function
|
|
1
|
+
/**
|
|
2
|
+
* Check if telemetry is enabled.
|
|
3
|
+
*
|
|
4
|
+
* Identity-based telemetry is mandatory for all commands except init and update.
|
|
5
|
+
* Opt-out mechanisms have been removed.
|
|
6
|
+
*
|
|
7
|
+
* Kept synchronous so call sites need not become async. Reads config via
|
|
8
|
+
* sync getGlobalConfig() rather than async getTelemetryConfig().
|
|
9
|
+
*/
|
|
10
|
+
export declare function isTelemetryEnabled(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Get the user identity for telemetry.
|
|
13
|
+
* Reads from identity file or environment variable.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getIdentity(): Promise<string | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Track a command execution.
|
|
18
|
+
*
|
|
19
|
+
* @param commandName - The command name (e.g., 'init', 'change:apply')
|
|
20
|
+
* @param version - The OpenSpec version
|
|
21
|
+
*/
|
|
22
|
+
export declare function trackCommand(commandName: string, version: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Track a comprehension quiz attempt.
|
|
25
|
+
*
|
|
26
|
+
* @param changeName - The name of the change
|
|
27
|
+
* @param attemptNumber - The attempt number
|
|
28
|
+
*/
|
|
29
|
+
export declare function trackComprehensionAttempt(changeName: string, attemptNumber: number): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Track a comprehension quiz completion.
|
|
32
|
+
*
|
|
33
|
+
* @param changeName - The name of the change
|
|
34
|
+
* @param scorePercent - The score percentage (0-100)
|
|
35
|
+
* @param result - The result ('pass' or 'fail')
|
|
36
|
+
* @param attemptNumber - The attempt number
|
|
37
|
+
*/
|
|
38
|
+
export declare function trackComprehensionCompletion(changeName: string, scorePercent: number, result: 'pass' | 'fail', attemptNumber: number): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Track when apply becomes ready after quiz pass.
|
|
41
|
+
*
|
|
42
|
+
* @param changeName - The name of the the change
|
|
43
|
+
*/
|
|
44
|
+
export declare function trackApplyReady(changeName: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Track artifact modification request.
|
|
47
|
+
*
|
|
48
|
+
* @param changeName - The name of the change
|
|
49
|
+
* @param artifactId - The artifact being modified
|
|
50
|
+
*/
|
|
51
|
+
export declare function trackArtifactModifyRequested(changeName: string, artifactId: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Track artifact revision request (when downstream artifacts need regeneration).
|
|
54
|
+
*
|
|
55
|
+
* @param changeName - The name of the change
|
|
56
|
+
* @param artifactId - The artifact being regenerated
|
|
57
|
+
*/
|
|
58
|
+
export declare function trackArtifactRevisionRequested(changeName: string, artifactId: string): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Track artifact content change.
|
|
61
|
+
*
|
|
62
|
+
* @param changeName - The name of the change
|
|
63
|
+
* @param artifactId - The artifact whose content changed
|
|
64
|
+
*/
|
|
65
|
+
export declare function trackArtifactContentChanged(changeName: string, artifactId: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Track workflow started event (when a new change is created).
|
|
68
|
+
*
|
|
69
|
+
* @param changeName - The name of the change
|
|
70
|
+
* @param workflowInput - Optional workflow input data
|
|
71
|
+
*/
|
|
72
|
+
export declare function trackWorkflowStarted(changeName: string, workflowInput?: Record<string, unknown>): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Track change proposal ready event (when proposal artifact is created).
|
|
75
|
+
*
|
|
76
|
+
* @param changeName - The name of the change
|
|
77
|
+
*/
|
|
78
|
+
export declare function trackChangeProposalReady(changeName: string): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Track change archived event (when a change is archived).
|
|
81
|
+
*
|
|
82
|
+
* @param changeName - The name of the change
|
|
83
|
+
*/
|
|
84
|
+
export declare function trackChangeArchived(changeName: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Track store operation event.
|
|
87
|
+
*
|
|
88
|
+
* @param operation - The store operation (add, remove, list, register, unregister, doctor)
|
|
89
|
+
* @param storeId - Optional store ID
|
|
90
|
+
*/
|
|
91
|
+
export declare function trackStoreOperation(operation: 'add' | 'remove' | 'list' | 'register' | 'unregister' | 'doctor', storeId?: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Track workset operation event.
|
|
94
|
+
*
|
|
95
|
+
* @param operation - The workset operation (create, list, open, remove)
|
|
96
|
+
* @param worksetName - Optional workset name
|
|
97
|
+
*/
|
|
98
|
+
export declare function trackWorksetOperation(operation: 'create' | 'list' | 'open' | 'remove', worksetName?: string): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Track validation operation event.
|
|
101
|
+
*
|
|
102
|
+
* @param changeName - The change name being validated
|
|
103
|
+
* @param result - Validation result (valid, invalid, warnings)
|
|
104
|
+
*/
|
|
105
|
+
export declare function trackValidationOperation(changeName: string, result: 'valid' | 'invalid' | 'warnings'): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Track config change event.
|
|
108
|
+
*
|
|
109
|
+
* @param operation - The config operation (set, unset)
|
|
110
|
+
* @param key - The config key being changed
|
|
111
|
+
*/
|
|
112
|
+
export declare function trackConfigChange(operation: 'set' | 'unset', key: string): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Track feedback submission event.
|
|
115
|
+
*
|
|
116
|
+
* @param category - Feedback category
|
|
117
|
+
*/
|
|
118
|
+
export declare function trackFeedbackSubmission(category: string): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Show first-run telemetry notice if not already seen.
|
|
121
|
+
*/
|
|
122
|
+
export declare function maybeShowTelemetryNotice(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Flush pending telemetry events.
|
|
125
|
+
* Call this before CLI exit.
|
|
126
|
+
*/
|
|
11
127
|
export declare function shutdown(): Promise<void>;
|
|
12
|
-
/** @internal Test helper */
|
|
13
|
-
export declare function resetTelemetryForTests(): void;
|
|
14
|
-
export { trackWorkflowStarted, maybeEmitProposalReady, maybeEmitApplyReady, trackArtifactInstructions, trackArtifactContentChanges, trackArtifactModifyRequested, trackChangeArchived, buildSpecDeltasFromUpdates, } from './workflow.js';
|
|
15
|
-
export { trackComprehensionAttempt, trackComprehensionGateChecked, trackComprehensionRetakeRequired, incrementComprehensionAttempt, incrementComprehensionFailureCount, enrichFromMarker, } from './comprehension.js';
|
|
16
|
-
export type { EntryPoint } from './marker.js';
|
|
17
128
|
//# sourceMappingURL=index.d.ts.map
|