Skip to content

Conversation

@Snider
Copy link
Owner

@Snider Snider commented Oct 30, 2025

This pull request refactors and modularizes the Core CLI's development commands, introduces a new docstring generation tool, and improves the CLI's structure for better maintainability and usability. The main changes include moving development-related commands into a dedicated dev package, adding a new docgen command for generating missing docstrings, cleaning up the task definitions, and updating documentation to reflect these improvements.

CLI Structure Refactoring and Modularization:

  • Moved development commands (api, sync, test-gen, build) into a new dev package, renaming files and updating package declarations accordingly for improved separation of concerns and maintainability. ([[1]](https://github.com/Snider/Core/pull/16/files#diff-df450d6975fc12b7e8f29f53784b7a8d58286d678df91d3081de23108a55d63aL1-R1), [[2]](https://github.com/Snider/Core/pull/16/files#diff-61bf840359fce5ed9fe4f582e553d2d55dd92440a7e9bb380e398d02f364ba66L1-R1), [[3]](https://github.com/Snider/Core/pull/16/files#diff-0f5ba18bb1c5b34071e97aba56731cf1d8c5676e17a94543eb0570582e231832L1-R1), [[4]](https://github.com/Snider/Core/pull/16/files#diff-8939b41aba5f1e3849637d795a9e9d44e9888e12b20119090076deb2276f981dL1-R1), [[5]](https://github.com/Snider/Core/pull/16/files#diff-8939b41aba5f1e3849637d795a9e9d44e9888e12b20119090076deb2276f981dL25-R26))
  • Updated the root CLI (root.go) to import and register commands from the new dev package, and added logic to detect development mode via environment variables or executable path. ([[1]](https://github.com/Snider/Core/pull/16/files#diff-9de3b93b599fb0d28257150d9b53050dc781c11b7bd17529e8d8876d3c0e1a5aR5-R17), [[2]](https://github.com/Snider/Core/pull/16/files#diff-9de3b93b599fb0d28257150d9b53050dc781c11b7bd17529e8d8876d3c0e1a5aR44-R57), [[3]](https://github.com/Snider/Core/pull/16/files#diff-9de3b93b599fb0d28257150d9b53050dc781c11b7bd17529e8d8876d3c0e1a5aL69-R103))
  • Removed the obsolete tview example command for a cleaner CLI. ([cmd/core/cmd/tview.goL1-L26](https://github.com/Snider/Core/pull/16/files#diff-3f00b6ce8aac490c9ce172c485ace52f6eacf18c2494b4d6df3bed9ba17cb2feL1-L26))

New Features and Tools:

  • Added a new docgen command (doc.go) to the dev package, which scans Go files for exported declarations missing docstrings and suggests placeholder comments. ([[1]](https://github.com/Snider/Core/pull/16/files#diff-436735aebe75b7546ea9d3bebc12e9d9e64e1364658470efc81231e076e806eaR1-R115), [[2]](https://github.com/Snider/Core/pull/16/files#diff-237f47b0168e3dae41d85759572baff70f3c7cb7ef606129216111a83729d9c7R1-R26))
  • Updated documentation (cmd/core/README.md) to describe the CLI, its purpose, and key packages, including usage examples. ([cmd/core/README.mdR1-R53](https://github.com/Snider/Core/pull/16/files#diff-368810641823ea55ffae7b869ad671b7395b34daa49e18e902919b784c986152R1-R53))

Taskfile and Build Process Improvements:

  • Moved development-related tasks (test-gen, sync, docgen) into cmd/core/cmd/dev/Taskfile.yml, and updated main Taskfiles to reference these via an include. This streamlines the build and development workflow. ([[1]](https://github.com/Snider/Core/pull/16/files#diff-e12cf821c8e4bd34d8563d1ad60bfee4f2cc26315a9374c0d0db49d4d481381bR5), [[2]](https://github.com/Snider/Core/pull/16/files#diff-e12cf821c8e4bd34d8563d1ad60bfee4f2cc26315a9374c0d0db49d4d481381bL20-R21), [[3]](https://github.com/Snider/Core/pull/16/files#diff-e12cf821c8e4bd34d8563d1ad60bfee4f2cc26315a9374c0d0db49d4d481381bL33-L39), [[4]](https://github.com/Snider/Core/pull/16/files#diff-e22dcbb6bd5b6cf7e49b0724fda09a9809eb415940002c1364145c894c41d742R4), [[5]](https://github.com/Snider/Core/pull/16/files#diff-237f47b0168e3dae41d85759572baff70f3c7cb7ef606129216111a83729d9c7R1-R26), [[6]](https://github.com/Snider/Core/pull/16/files#diff-cd2d359855d0301ce190f1ec3b4c572ea690c83747f6df61c9340720e3d2425eL45-L54))
  • Adjusted the run task to use the correct build task from the included files. ([cmd/core/Taskfile.ymlL20-R21](https://github.com/Snider/Core/pull/16/files#diff-e12cf821c8e4bd34d8563d1ad60bfee4f2cc26315a9374c0d0db49d4d481381bL20-R21))

Other Improvements:

  • Added a CodeRabbit pull request review badge to the main README.md for improved project visibility. ([README.mdR3-R4](https://github.com/Snider/Core/pull/16/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R3-R4))
  • Made minor code cleanups and docstring improvements in the PWA build logic. ([[1]](https://github.com/Snider/Core/pull/16/files#diff-8939b41aba5f1e3849637d795a9e9d44e9888e12b20119090076deb2276f981dL84-R108), [[2]](https://github.com/Snider/Core/pull/16/files#diff-8939b41aba5f1e3849637d795a9e9d44e9888e12b20119090076deb2276f981dL166-R177))

These changes collectively make the CLI more modular, easier to extend, and more developer-friendly.

… generation command, and update Taskfile for new tasks

Signed-off-by: Snider <snider@lt.hn>
Signed-off-by: Snider <snider@lt.hn>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added documentation generation command to identify and report missing docstrings for exported code declarations.
    • Added development mode detection for the Core CLI with banner gating.
  • Removals

    • Removed tview-example command from the CLI.
    • Removed top-level sync and test-gen tasks; now available within the dev namespace.
  • Documentation

    • Added Core CLI documentation with usage examples and key package references.

Walkthrough

The changes restructure the CLI command architecture by moving development tasks into a dedicated dev package. Top-level Taskfile tasks are consolidated, package declarations are reorganized, command signatures are updated to use a parent-based approach, and dev-mode detection logic is added to conditionally gate command registration and features. The tview command is removed entirely.

Changes

Cohort / File(s) Summary
Documentation
README.md, cmd/core/README.md
Added CodeRabbit PRs badge to README. Created new Core CLI documentation file describing tasks, dependencies, and providing a clir usage example.
Taskfile restructuring
Taskfile.yml
Removed top-level sync and test-gen tasks from root Taskfile.
Taskfile restructuring
cmd/core/Taskfile.yml
Added dev include reference, updated run task to invoke "cmd:build" instead of "build", removed test-gen task.
Taskfile restructuring
cmd/core/cmd/Taskfile.yml
Added blank line after tasks key for formatting.
Taskfile restructuring
cmd/core/cmd/dev/Taskfile.yml
New Taskfile with docgen, test-gen, and sync tasks, each platform-gated to Linux/macOS.
Dev package reorganisation
cmd/core/cmd/dev/{api,sync,test_gen}.go
Changed package declarations from cmd to dev for api.go, sync.go, and test_gen.go.
Dev package—new documentation command
cmd/core/cmd/dev/doc.go
New file implementing AddDocCommand to scan and report missing docstrings for exported declarations.
Dev package—build command updates
cmd/core/cmd/dev/pwa-build.go
Changed package from cmd to dev, updated AddBuildCommand signature to accept parent command, commented out manifest downloading logic, updated fetchManifest signature.
Root command restructuring
cmd/core/cmd/root.go
Added IsDevMode boolean flag, implemented dev-mode detection via executable path and environment variables, refactored command wiring to use dev package helpers, gated banner rendering on IsDevMode.
Command removal
cmd/core/cmd/tview.go
Removed entire AddTviewCommand function and associated tview-example subcommand.

Sequence Diagram

sequenceDiagram
    participant main as main()
    participant root as cmd.Execute()
    participant env as Env/Exec Path
    participant dev as dev Package
    participant banner as Banner Render

    main->>root: Call Execute()
    root->>env: Check executable path & DEV/CI env vars
    env-->>root: Path contains "Core/cmd/core/bin/" + env set?
    root->>root: Set IsDevMode = true/false
    
    alt IsDevMode = true
        root->>dev: Register dev commands<br/>(dev.AddAPICommands,<br/>dev.AddTestGenCommand, etc.)
        dev-->>root: Commands registered under devCmd
    else IsDevMode = false
        root->>root: Skip dev command registration
    end
    
    alt IsDevMode = true
        root->>banner: Render ASCII banner
    else IsDevMode = false
        root->>banner: Skip banner
    end
    
    root-->>main: Return
Loading

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 Commands hop into dev's cosy burrow,
Tasks reorganised, no need to borrow,
Modes now detected with care and with grace,
The CLI's structure finds its new place!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "CLI code-docgen function" refers to a real and significant aspect of the changeset—the new docgen command for generating missing docstrings for exported Go declarations. However, the PR's primary objective, as documented in the description and objectives, is the broader refactoring and modularisation of the Core CLI by moving development commands into a dedicated dev package. The title captures one important addition but does not emphasise the core architectural restructuring and separation of concerns that drives the majority of the changes.
Description Check ✅ Passed The pull request description is comprehensive and clearly related to the changeset. It provides detailed explanations of the main refactoring effort (moving commands to a dev package), the new features added (the docgen command), the Taskfile and build process improvements, and other enhancements such as updated documentation and the CodeRabbit badge. The description uses specific references to files, functions, and structural changes, demonstrating a clear understanding of what has been modified and why. It is neither vague nor off-topic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev-docstring-gen

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added the enhancement New feature or request label Oct 30, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cmd/core/cmd/dev/pwa-build.go (1)

83-112: Do not remove manifest-driven asset downloads

Commenting out the manifest discovery/fetch loop means downloadPWA now writes only index.html and skips every CSS/JS/icon listed in the manifest. Any PWA built through this path will miss its static assets and fail the moment it starts offline or without network access. Please restore the manifest handling (or replace it with an equivalent asset fetch) so the command still produces a runnable bundle.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 111e5e1 and 78806ff.

📒 Files selected for processing (13)
  • README.md (1 hunks)
  • Taskfile.yml (0 hunks)
  • cmd/core/README.md (1 hunks)
  • cmd/core/Taskfile.yml (2 hunks)
  • cmd/core/cmd/Taskfile.yml (1 hunks)
  • cmd/core/cmd/dev/Taskfile.yml (1 hunks)
  • cmd/core/cmd/dev/api.go (1 hunks)
  • cmd/core/cmd/dev/doc.go (1 hunks)
  • cmd/core/cmd/dev/pwa-build.go (4 hunks)
  • cmd/core/cmd/dev/sync.go (1 hunks)
  • cmd/core/cmd/dev/test_gen.go (1 hunks)
  • cmd/core/cmd/root.go (3 hunks)
  • cmd/core/cmd/tview.go (0 hunks)
💤 Files with no reviewable changes (2)
  • cmd/core/cmd/tview.go
  • Taskfile.yml
🧰 Additional context used
🧬 Code graph analysis (2)
cmd/core/cmd/dev/test_gen.go (1)
cmd/core/cmd/test_gen.go (2)
  • AddTestGenCommand (16-26)
  • runTestGen (61-90)
cmd/core/cmd/root.go (5)
cmd/core/cmd/dev/api.go (1)
  • AddAPICommands (8-17)
cmd/core/cmd/dev/test_gen.go (1)
  • AddTestGenCommand (16-26)
cmd/core/cmd/dev/sync.go (1)
  • AddSyncCommand (19-29)
cmd/core/cmd/dev/doc.go (1)
  • AddDocCommand (16-115)
cmd/core/cmd/dev/pwa-build.go (1)
  • AddBuildCommand (25-49)
🪛 LanguageTool
cmd/core/README.md

[uncategorized] ~18-~18: Loose punctuation mark.
Context: ... github.com/charmbracelet/lipgloss: A library for styling terminal output. ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~20-~20: Loose punctuation mark.
Context: ...github.com/common-nighthawk/go-figure`**: Used to create ASCII art text banners, ...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~22-~22: Loose punctuation mark.
Context: ...age. - github.com/leaanthony/clir: A simple and lightweight library for cr...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 YAMLlint (1.37.1)
cmd/core/cmd/dev/Taskfile.yml

[error] 14-14: too many spaces inside brackets

(brackets)


[error] 14-14: too many spaces inside brackets

(brackets)


[error] 17-17: too many spaces inside brackets

(brackets)


[error] 17-17: too many spaces inside brackets

(brackets)


[error] 22-22: too many spaces inside brackets

(brackets)


[error] 22-22: too many spaces inside brackets

(brackets)


[error] 25-25: too many spaces inside brackets

(brackets)


[error] 25-25: too many spaces inside brackets

(brackets)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: CodeQL
🔇 Additional comments (9)
README.md (1)

3-4: LGTM!

The CodeRabbit badge addition improves project visibility and provides quick access to PR review status.

cmd/core/cmd/dev/test_gen.go (1)

1-1: LGTM!

The package rename to dev correctly aligns this file with the new dev-subpackage structure, supporting the modularization of development commands.

cmd/core/cmd/dev/api.go (1)

1-1: LGTM!

The package rename to dev is consistent with the broader refactoring effort to modularize development commands.

cmd/core/cmd/Taskfile.yml (1)

4-4: LGTM!

The formatting adjustment improves readability without affecting functionality.

cmd/core/cmd/dev/sync.go (1)

1-1: LGTM!

The package rename to dev maintains consistency with the new package structure for development commands.

cmd/core/README.md (1)

1-53: Excellent documentation!

The README clearly explains the CLI's purpose, key dependencies, and provides a helpful usage example. The structure and content will greatly aid developers working with the Core CLI.

cmd/core/Taskfile.yml (2)

5-5: LGTM!

Adding the dev Taskfile include properly exposes development tasks under the dev: namespace, supporting the modularization of dev commands.


21-21: LGTM!

Updating the reference to cmd:build correctly uses the namespaced task from the included cmd Taskfile, maintaining consistency with the new task organization.

cmd/core/cmd/dev/Taskfile.yml (1)

6-6: The build dependency resolution is correct—no changes required.

The deps: [build] references in the dev Taskfile resolve correctly to the build task defined in the parent cmd/core/Taskfile.yml. When a Taskfile is included with a namespace, its tasks can directly reference tasks from the parent Taskfile without qualification. Namespace-qualified references (e.g., cmd:build) are only necessary to access tasks from sibling includes, not the parent context.

Likely an incorrect or invalid review comment.

Comment on lines +53 to +71
for _, decl := range node.Decls {
switch d := decl.(type) {
case *ast.GenDecl:
if d.Doc == nil || len(d.Doc.List) == 0 {
for _, spec := range d.Specs {
switch s := spec.(type) {
case *ast.TypeSpec:
if ast.IsExported(s.Name.Name) {
reports = append(reports, fmt.Sprintf("%s:%d: Missing docstring for type %s. Suggested: // %s ...", path, fset.Position(s.Pos()).Line, s.Name.Name, s.Name.Name))
}
case *ast.ValueSpec: // For var and const
for _, name := range s.Names {
if ast.IsExported(name.Name) {
reports = append(reports, fmt.Sprintf("%s:%d: Missing docstring for %s %s. Suggested: // %s ...", path, fset.Position(name.Pos()).Line, d.Tok.String(), name.Name, name.Name))
}
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Account for spec-level doc comments

When a type, const, or var is documented via spec.Doc inside a grouped declaration, d.Doc is nil, so this code wrongly reports a missing docstring even though one exists (common pattern for grouped declarations). Please check the spec’s own comment before flagging it to avoid constant false positives.

-					case *ast.GenDecl:
-						if d.Doc == nil || len(d.Doc.List) == 0 {
+					case *ast.GenDecl:
+						genDocMissing := d.Doc == nil || len(d.Doc.List) == 0
 						for _, spec := range d.Specs {
 							switch s := spec.(type) {
 							case *ast.TypeSpec:
-								if ast.IsExported(s.Name.Name) {
+								if ast.IsExported(s.Name.Name) && (genDocMissing && (s.Doc == nil || len(s.Doc.List) == 0)) {
 									reports = append(reports, fmt.Sprintf("%s:%d: Missing docstring for type %s. Suggested: // %s ...", path, fset.Position(s.Pos()).Line, s.Name.Name, s.Name.Name))
 								}
 							case *ast.ValueSpec: // For var and const
 								for _, name := range s.Names {
-									if ast.IsExported(name.Name) {
+									if ast.IsExported(name.Name) && (genDocMissing && (s.Doc == nil || len(s.Doc.List) == 0)) {
 										reports = append(reports, fmt.Sprintf("%s:%d: Missing docstring for %s %s. Suggested: // %s ...", path, fset.Position(name.Pos()).Line, d.Tok.String(), name.Name, name.Name))
 									}
 								}
 							}
-						}
+						}

Comment on lines +8 to +10
- cmd: chmod +x ../../bin/core
platforms: [linux, darwin]
- "../../bin/core dev doc"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix path inconsistency.

The docgen task uses relative paths (../../bin/core) whilst the other tasks use {{.TASKFILE_DIR}}/bin/core. This inconsistency could cause issues if the Taskfile location changes or when tasks are invoked from different contexts.

Apply this diff to use consistent path references:

     cmds:
-      - cmd: chmod +x ../../bin/core
+      - cmd: chmod +x {{.TASKFILE_DIR}}/../../bin/core
         platforms: [linux, darwin]
-      - "../../bin/core dev doc"
+      - "{{.TASKFILE_DIR}}/../../bin/core dev doc"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- cmd: chmod +x ../../bin/core
platforms: [linux, darwin]
- "../../bin/core dev doc"
- cmd: chmod +x {{.TASKFILE_DIR}}/../../bin/core
platforms: [linux, darwin]
- "{{.TASKFILE_DIR}}/../../bin/core dev doc"
🤖 Prompt for AI Agents
In cmd/core/cmd/dev/Taskfile.yml around lines 8 to 10, the docgen task uses a
relative path ../../bin/core which is inconsistent with other tasks using
{{.TASKFILE_DIR}}/bin/core; update both the chmod command and the task
invocation to use {{.TASKFILE_DIR}}/bin/core so the Taskfile uses a stable,
location-independent reference (keep the platforms list and other task fields
unchanged).


test-gen:
summary: Generates tests for the public API
deps: [ build ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove extra spaces from array brackets.

YAML linting flags the inconsistent spacing in deps: [ build ] and platforms: [ linux, darwin ]. Arrays should not have spaces inside brackets.

Apply this diff to fix the formatting:

-    deps: [ build ]
+    deps: [build]
     cmds:
-      - cmd: chmod +x {{.TASKFILE_DIR}}/bin/core
-        platforms: [ linux, darwin ]
+      - cmd: chmod +x {{.TASKFILE_DIR}}/../../bin/core
+        platforms: [linux, darwin]
       - "{{.TASKFILE_DIR}}/bin/core dev test-gen"

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 14-14: too many spaces inside brackets

(brackets)


[error] 14-14: too many spaces inside brackets

(brackets)

🤖 Prompt for AI Agents
In cmd/core/cmd/dev/Taskfile.yml around line 14, the array spacing is
inconsistent: change "deps: [ build ]" to remove spaces inside the brackets (use
"deps: [build]"); also find the platforms array occurrence and change
"platforms: [ linux, darwin ]" to "platforms: [linux, darwin]" so there are no
spaces directly inside the square brackets to satisfy YAML linting.

Comment on lines +22 to +25
deps: [ build ]
cmds:
- cmd: chmod +x {{.TASKFILE_DIR}}/bin/core
platforms: [ linux, darwin ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove extra spaces from array brackets.

Same formatting issue as in the test-gen task.

Apply this diff:

-    deps: [ build ]
+    deps: [build]
     cmds:
-      - cmd: chmod +x {{.TASKFILE_DIR}}/bin/core
-        platforms: [ linux, darwin ]
+      - cmd: chmod +x {{.TASKFILE_DIR}}/../../bin/core
+        platforms: [linux, darwin]
       - "{{.TASKFILE_DIR}}/bin/core dev sync"

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 22-22: too many spaces inside brackets

(brackets)


[error] 22-22: too many spaces inside brackets

(brackets)


[error] 25-25: too many spaces inside brackets

(brackets)


[error] 25-25: too many spaces inside brackets

(brackets)

🤖 Prompt for AI Agents
In cmd/core/cmd/dev/Taskfile.yml around lines 22 to 25, remove the extra spaces
inside the array brackets so the deps and platforms arrays use bracketed lists
without leading/trailing spaces: change "deps: [ build ]" to "deps: [build]" and
change "platforms: [ linux, darwin ]" to "platforms: [linux, darwin]".

Comment on lines +45 to +56
executablePath, err := os.Executable()
if err == nil {
// Check if the executable path contains the build path for dev mode
if strings.Contains(executablePath, "Core/cmd/core/bin/") {
IsDevMode = true
}
}

// Check for DEV or CI environment variables
if os.Getenv("DEV") != "" || os.Getenv("CI") != "" {
IsDevMode = true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Normalise executable path before substring check

os.Executable() returns paths with \ on Windows, so strings.Contains(executablePath, "Core/cmd/core/bin/") will never match there. Dev mode stays false, the banner (and any future dev-only gating) never triggers, effectively breaking the feature for every Windows dev build. Please normalise the path first:

-	executablePath, err := os.Executable()
-	if err == nil {
-		// Check if the executable path contains the build path for dev mode
-		if strings.Contains(executablePath, "Core/cmd/core/bin/") {
+	executablePath, err := os.Executable()
+	if err == nil {
+		normalised := filepath.ToSlash(executablePath)
+		if strings.Contains(normalised, "Core/cmd/core/bin/") {
 			IsDevMode = true
 		}
 	}

(remember to add path/filepath to the imports).

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In cmd/core/cmd/root.go around lines 45 to 56, os.Executable() can return
Windows paths with backslashes so the substring check against
"Core/cmd/core/bin/" will never match on Windows; normalize the executablePath
using filepath.ToSlash (after adding "path/filepath" to imports) and then
perform the strings.Contains check against the normalized path (optionally also
call filepath.Clean before ToSlash to be safe), preserving existing error
handling and the rest of the logic.

@Snider Snider changed the base branch from dev to feature-tdd-contract-testing November 2, 2025 15:45
@Snider Snider merged commit ae3a708 into feature-tdd-contract-testing Nov 2, 2025
4 checks passed
@Snider Snider deleted the dev-docstring-gen branch November 2, 2025 15:45
Snider added a commit that referenced this pull request Nov 2, 2025
* feat: Implement TDD contract testing for public API

This commit introduces a Test-Driven Development (TDD) workflow to enforce the public API contract. A new `tdd/` directory has been added to house these tests, which are intended to be the starting point for any new features or bug fixes that affect the public interface.

The "Good, Bad, Ugly" testing methodology has been adopted for these tests:
- `_Good` tests verify the "happy path" with valid inputs.
- `_Bad` tests verify predictable errors with invalid inputs.
- `_Ugly` tests verify edge cases and unexpected inputs to prevent panics.

TDD contract tests have been implemented for the `core` and `config` packages, and the `core.New` function has been hardened to prevent panics from `nil` options.

The `README.md` has been updated to document this new workflow.

* feat: Add TDD contract tests for all services

This commit expands the TDD contract testing framework to cover all services in the application. "Good, Bad, Ugly" tests have been added for the `help`, `i18n`, and `workspace` services.

To facilitate testing, the following refactors were made:
- `help`: Added a `SetDisplay` method to allow for mock injection. Hardened `Show` and `ShowAt` to prevent panics.
- `i18n`: Added a `SetBundle` method to allow for loading test-specific localization files.
- `workspace`: Made the `Config` field public and added a `SetMedium` method to allow for mock injection.

The TDD tests for the `crypt` service have been skipped due to issues with PGP key generation in the test environment.

* CLI code-docgen function (#16)

* Refactor CLI structure: move commands to 'dev' package, add docstring generation command, and update Taskfile for new tasks

Signed-off-by: Snider <snider@lt.hn>

* Add CodeRabbit PR review badge to README

Signed-off-by: Snider <snider@lt.hn>

---------

Signed-off-by: Snider <snider@lt.hn>

---------

Signed-off-by: Snider <snider@lt.hn>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Snider added a commit that referenced this pull request Nov 2, 2025
* refactor: Rearchitect library to use runtime and pkg modules

This commit introduces a major architectural refactoring to simplify the library's structure and improve its maintainability.

Key changes include:

- **Simplified Project Structure:** All top-level facade packages (config, crypt, display, etc.) and the root `core.go` have been removed. All library code now resides directly under the `pkg/` directory.

- **Unified Runtime:** A new `pkg/runtime` module with a `New()` constructor has been introduced. This function initializes and wires together all core services, providing a single, convenient entry point for applications.

- **Updated Entry Points:** The `cmd/core-gui` application and all examples have been updated to use the new `runtime.New()` initialization.

- **Internal Packages:** The `config` and `crypt` packages have been refactored to use an `internal` subdirectory for their implementation. This hides private details and exposes a clean, stable public API.

- **Standardized Error Handling:** A new error handling package has been added at `pkg/e`. The `workspace` and `crypt` services have been updated to use this new standard.

- **Improved Feature Flagging:** A `IsFeatureEnabled` method was added to the `config` service for more robust and centralized feature flag checks.

- **CI and Dependencies:**
  - A GitHub Actions workflow has been added for continuous integration.
  - All Go dependencies have been updated to their latest versions.

- **Documentation:** All documentation has been updated to reflect the new, simplified architecture, and obsolete files have been removed.

* refactor: Rearchitect library to use runtime and pkg modules

This commit introduces a major architectural refactoring to simplify the library's structure and improve its maintainability.

Key changes include:

- **Simplified Project Structure:** All top-level facade packages (config, crypt, display, etc.) and the root `core.go` have been removed. All library code now resides directly under the `pkg/` directory.

- **Unified Runtime:** A new `pkg/runtime` module with a `New()` constructor has been introduced. This function initializes and wires together all core services, providing a single, convenient entry point for applications. The runtime now accepts the Wails application instance, ensuring proper integration with the GUI.

- **Updated Entry Points:** The `cmd/core-gui` application and all examples have been updated to use the new `runtime.New()` constructor and correctly register the runtime as a Wails service.

- **Internal Packages:** The `config` and `crypt` packages have been refactored to use an `internal` subdirectory for their implementation. This hides private details and exposes a clean, stable public API.

- **Standardized Error Handling:** A new error handling package has been added at `pkg/e`. The `workspace` and `crypt` services have been updated to use this new standard.

- **Improved Feature Flagging:** A `IsFeatureEnabled` method was added to the `config` service for more robust and centralized feature flag checks.

- **CI and Dependencies:**
  - A GitHub Actions workflow has been added for continuous integration.
  - All Go dependencies have been updated to their latest versions.

- **Documentation:** All documentation has been updated to reflect the new, simplified architecture, and obsolete files have been removed.

* Feature tdd contract testing (#19)

* feat: Implement TDD contract testing for public API

This commit introduces a Test-Driven Development (TDD) workflow to enforce the public API contract. A new `tdd/` directory has been added to house these tests, which are intended to be the starting point for any new features or bug fixes that affect the public interface.

The "Good, Bad, Ugly" testing methodology has been adopted for these tests:
- `_Good` tests verify the "happy path" with valid inputs.
- `_Bad` tests verify predictable errors with invalid inputs.
- `_Ugly` tests verify edge cases and unexpected inputs to prevent panics.

TDD contract tests have been implemented for the `core` and `config` packages, and the `core.New` function has been hardened to prevent panics from `nil` options.

The `README.md` has been updated to document this new workflow.

* feat: Add TDD contract tests for all services

This commit expands the TDD contract testing framework to cover all services in the application. "Good, Bad, Ugly" tests have been added for the `help`, `i18n`, and `workspace` services.

To facilitate testing, the following refactors were made:
- `help`: Added a `SetDisplay` method to allow for mock injection. Hardened `Show` and `ShowAt` to prevent panics.
- `i18n`: Added a `SetBundle` method to allow for loading test-specific localization files.
- `workspace`: Made the `Config` field public and added a `SetMedium` method to allow for mock injection.

The TDD tests for the `crypt` service have been skipped due to issues with PGP key generation in the test environment.

* CLI code-docgen function (#16)

* Refactor CLI structure: move commands to 'dev' package, add docstring generation command, and update Taskfile for new tasks

Signed-off-by: Snider <snider@lt.hn>

* Add CodeRabbit PR review badge to README

Signed-off-by: Snider <snider@lt.hn>

---------

Signed-off-by: Snider <snider@lt.hn>

---------

Signed-off-by: Snider <snider@lt.hn>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

* Update pkg/runtime/runtime.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* feat: Rearchitect library and add automated documentation

This commit introduces a major architectural refactoring of the Core library and adds a new, automated documentation system.

**Architectural Changes:**

*   **Unified Runtime:** A new `pkg/runtime` module provides a single `runtime.New()` constructor that initializes and manages all core services. This simplifies application startup and improves maintainability.
*   **Wails Integration:** The `Runtime` is now correctly integrated with the Wails application lifecycle, accepting the `*application.App` instance and being registered as a Wails service.
*   **Simplified Project Structure:** All top-level facade packages have been removed, and library code is now consolidated under the `pkg/` directory.
*   **Internal Packages:** The `config` and `crypt` services now use an `internal` package to enforce a clean separation between public API and implementation details.
*   **Standardized Error Handling:** The `pkg/e` package has been introduced and integrated into the `workspace` and `crypt` services for consistent error handling.
*   **Graceful Shutdown:** The shutdown process has been fixed to ensure shutdown signals are correctly propagated to all services.

**Documentation:**

*   **Automated Doc Generation:** A new `docgen` command has been added to `cmd/core` to automatically generate Markdown documentation from the service source code.
*   **MkDocs Site:** A new MkDocs Material documentation site has been configured in the `/docs` directory.
*   **Deployment Workflow:** A new GitHub Actions workflow (`.github/workflows/docs.yml`) automatically builds and deploys the documentation site to GitHub Pages.

**Quality Improvements:**

*   **Hermetic Tests:** The config service tests have been updated to be fully hermetic, running in a temporary environment to avoid side effects.
*   **Panic Fix:** A panic in the config service's `Set` method has been fixed, and "Good, Bad, Ugly" tests have been added to verify the fix.
*   **CI/CD:** The CI workflow has been updated to use the latest GitHub Actions.
*   **Code Quality:** Numerous smaller fixes and improvements have been made based on CI feedback.

---------

Signed-off-by: Snider <snider@lt.hn>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants