@foggy-projects/deepseek-harness-plugin 0.4.0-beta.9 → 0.4.0-rc.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.
@@ -1,156 +1,168 @@
1
- # Resumable database onboarding
2
-
3
- Use the thin `scripts/onboard.ps1` or `scripts/onboard.sh` entrypoint. Every command emits one JSON
4
- object. Preserve the returned `next` instruction and use `onboard-status` or `onboard-resume` after an
5
- interruption.
1
+ # Development datasource and semantic-model workflow
2
+
3
+ Use this workflow after the Foggy plugin is initialized. It is designed for local experience and
4
+ model development in DeepSeek Harness, not for production deployment.
5
+
6
+ ## Connection input
7
+
8
+ The simplest local connection contract may contain a direct password:
9
+
10
+ ```json
11
+ {
12
+ "schemaVersion": "foggy-deepseek-connection/v1",
13
+ "profile": "business",
14
+ "name": "business-db",
15
+ "type": "mysql",
16
+ "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/business",
17
+ "username": "business_dev",
18
+ "password": "local-development-password",
19
+ "namespace": "business",
20
+ "modelsDir": "models",
21
+ "evidenceDir": ".foggy/onboarding-command-evidence/business"
22
+ }
23
+ ```
6
24
 
7
- The wrapper is mandatory for the entire sequence below. Until `onboard-status` returns
8
- `next.status=completed`, do not substitute direct `foggy-runtime datasources`, `tables`, `sql`, `models`,
9
- `bundles`, or `query` calls. A second Skill may help write draft TM/QM files, but must not take over
10
- orchestration. Do not inspect sample rows to author the semantic layer; use schema metadata plus the
11
- business definitions confirmed by the user.
25
+ The wrapper uses the direct password only while submitting the datasource to the public Runtime API.
26
+ It does not copy it into onboarding state, command evidence, TM/QM files, or conversational output.
27
+ The source connection file is user-managed; do not commit it. The local Runtime currently stores a
28
+ direct password in its private datasource registry, so use `passwordRef`-style production credential
29
+ management when moving beyond local development.
30
+
31
+ An environment variable is an optional alternative:
32
+
33
+ ```json
34
+ {
35
+ "schemaVersion": "foggy-deepseek-connection/v1",
36
+ "profile": "business",
37
+ "name": "business-db",
38
+ "type": "mysql",
39
+ "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/business",
40
+ "username": "business_dev",
41
+ "passwordEnv": "FOGGY_BUSINESS_DB_PASSWORD",
42
+ "namespace": "business",
43
+ "modelsDir": "models"
44
+ }
45
+ ```
12
46
 
13
- ## Conversation contract
47
+ Here `passwordEnv` is read by the onboarding wrapper and submitted online to the already-running
48
+ Runtime. Do not restart Runtime merely to make the variable part of the Java process environment.
49
+ Opaque CLI profiles remain supported for users who already prefer them, but are not required for a
50
+ normal DSH experience.
14
51
 
15
- Collect these non-secret values before creating a plan:
52
+ ## Normal sequence
16
53
 
17
- 1. an opaque Foggy profile ID and its exact reviewed revision;
18
- 2. datasource name, database type, and namespace from the CLI's public profile summary;
19
- 3. optional schemas, the project-relative semantic model directory, and a project-relative evidence directory.
54
+ Run the platform-specific wrapper from this Skill directory. `onboard-datasource-run` performs the
55
+ online datasource setup, namespace binding, and schema discovery against the healthy Runtime:
20
56
 
21
- Create the private profile in a trusted operator session outside DeepSeek Harness. Do not ask the user
22
- to paste a password and do not put a JDBC URL, username, password environment-variable name, or password in the JSON plan, command
23
- line, logs, or evidence. For non-SQLite databases, ask the user to set the named environment variable
24
- before Runtime starts so the Java process inherits it. Recommend a read-only database account.
57
+ ```text
58
+ onboard-datasource-run --project-root <current-workspace> \
59
+ --connection-file <connection-json> \
60
+ --approve-configure --approve-bind --include-indexes
61
+ ```
25
62
 
26
- Use the current DSH session workspace as `projectRoot`. Store approved non-secret contracts at
27
- `.foggy/onboarding-contracts/<profile>/`, semantic drafts at `.foggy/onboarding-drafts/<profile>/`, and
28
- command evidence at `.foggy/onboarding-command-evidence/<profile>/`. Do not split these files across the
29
- session workspace and a separate example repository. The wrapper rejects a query payload outside the
30
- recorded project root before any semantic validation or publication mutation occurs.
63
+ If the user already requested the complete connection experience, include both approval flags in the
64
+ first call. They refer only to adding the named development datasource and binding the requested
65
+ namespace. Do not add `--replace` unless replacement was explicitly requested.
31
66
 
32
- The wrapper defaults `FOGGY_RUNTIME_PROFILE_STORE` to the private persistent directory
33
- `<dataRoot>/cli-profiles`. An explicit operator-provided value still wins. Do not use `/tmp` for a profile
34
- that must survive a WSL or Harness restart.
67
+ The command performs:
35
68
 
36
- If plugin settings detect profiles in the legacy temporary store, use **Move to persistent store**.
37
- Migration validates the opaque profile schema, rejects embedded passwords and conflicts, writes the
38
- destination with private permissions, verifies it, and moves the legacy JSON to a recoverable private
39
- backup below the Foggy data root.
40
- Do not manually copy or edit opaque profile JSON.
69
+ ```text
70
+ datasource add -> datasource test -> namespace bind -> diagnostics
71
+ tables list -> bounded schema inspection
72
+ ```
41
73
 
42
- Treat every user-supplied identifier and bound as immutable input: profile, datasource, namespace,
43
- models directory, bundle name, TM/QM name, query fields, and limit. Do not swap in demo names, add
44
- fields, raise the limit, or introduce replacement flags. If one of these inputs is missing, pause for
45
- that input rather than inventing it.
74
+ It does not stop or restart Runtime. Repeated calls reuse completed checkpoints when the public
75
+ connection contract is unchanged. Before reusing a datasource checkpoint, the wrapper verifies that
76
+ the named datasource still exists with the expected public type in the live Runtime. If it was
77
+ removed outside the wrapper, datasource configuration, verification, and schema discovery resume
78
+ automatically from the first affected step. Inline password values are excluded from the comparison.
79
+ Transient connection-pool readiness timeouts are retried a small, bounded number of times; invalid
80
+ credentials, invalid URLs, and other configuration errors fail immediately.
46
81
 
47
- For composite Harness execution, persist `profile` and `evidenceDir` inside both approved contract
48
- files. The wrapper derives them from the files and rejects conflicting command-line values. Present the
49
- normalized contracts to the user before accepting mutation approvals; do not combine contract drafting
50
- and approval into an unseen one-turn mutation.
82
+ When the user's request clearly identifies a business subject or likely tables, add `--pattern` or
83
+ one or more `--table` arguments so discovery remains focused. Do not enumerate CLI help, inspect the
84
+ wrapper source, load unrelated examples, or fetch online documentation on the successful normal path.
85
+ Keep full command payloads in the numbered evidence files and use only their concise result fields in
86
+ the conversation.
51
87
 
52
- Write the non-secret input using `assets/connection.schema.json`; `assets/datasource.example.json` is a
53
- template. Then execute the sequence below.
88
+ After discovery, use `foggy-ai-analysis` to create TM/QM drafts from actual tables, columns, keys,
89
+ small read-only samples when useful, and the user's business questions. Keep the files in the current
90
+ workspace, normally:
54
91
 
55
- ## Deterministic sequence
92
+ ```text
93
+ models/
94
+ model/
95
+ <Name>.tm
96
+ query/
97
+ <Name>QueryModel.qm
98
+ ```
56
99
 
57
- For Harness-driven onboarding, use the two composite commands below. Each writes the numbered JSON
58
- evidence internally and refuses to cross an unapproved mutation gate:
100
+ Then run the semantic composite:
59
101
 
60
102
  ```text
61
- onboard-datasource-run --project-root <current-session-workspace> \
62
- --connection-file <approved-json> \
63
- --approve-configure --approve-bind --include-indexes
64
-
65
- # After authoring the registered TM/QM draft from schema metadata:
66
- onboard-semantic-run --project-root <current-session-workspace> \
67
- --semantic-plan <approved-json> --query-payload <approved-json> \
103
+ onboard-semantic-run --project-root <current-workspace> \
104
+ --semantic-plan <semantic-json> \
105
+ --query-payload <bounded-query-json> \
68
106
  --approve-validate --approve-publish --approve-execute
69
107
  ```
70
108
 
71
- Include an approval flag only after the user approves that exact action. Without it, the composite
72
- command stops after the corresponding dry-run and returns `phaseStatus=awaiting-...-approval`.
109
+ For an explicitly requested end-to-end local experience, these flags may be used together. The command
110
+ validates the model files, copies them to the approved model directory when needed, registers or
111
+ updates the local Runtime Bundle, refreshes/describes the declared QueryModels, validates the bounded
112
+ query, and executes it. It never means production publication.
73
113
 
74
- Both composite commands are resumable. When the approved contract is unchanged, they skip completed
75
- checkpoints instead of re-adding an existing datasource, revalidating an already published draft, or
76
- registering the same bundle twice. If query validation fails after publication, correct the project-local
77
- payload and rerun `onboard-semantic-run`; it resumes at query verification and leaves the active bundle in
78
- place. A same-name datasource is accepted idempotently only when its public name and database type match
79
- the approved plan; otherwise replacement still requires explicit approval.
114
+ The composite result keeps `success=true` when the Runtime safely continues with warnings and exposes
115
+ `warningCount`, `warningCodes`, and `warnings` to the Agent. The full Runtime responses remain in
116
+ `query-validate.json` and `query-execute.json`. Read the structured warning facts rather than relying
117
+ on free-text remediation alone: compare `path`, `suggestedNextAction`, `safeToAutoRepair`,
118
+ `normalizedFragment`, `docsRef`, and `details.allowedProperties` with the described
119
+ model, correct and revalidate when an equivalent supported query preserves the user's intent, or
120
+ clearly report the degraded interpretation. The wrapper accepts Runtime 0.1.21
121
+ `queryInputWarnings` and legacy `warnings` as separate warning kinds. In `IGNORE`, ordinary unknown
122
+ properties continue without `queryInputWarnings`; in `STRICT`, the Runtime rejects the query with the
123
+ complete violations. Protected and governance fields remain fail-closed in every mode.
80
124
 
81
- When a completed profile already belongs to another workspace, the datasource composite may add the
82
- current workspace as a binding only if the approved connection contract is identical and the datasource,
83
- schema, and semantic publication checkpoints are complete. The semantic composite then accepts the same
84
- published draft digest from the bound workspace and performs a workspace-specific bounded verification
85
- query. It refuses semantic replacement from the secondary workspace.
125
+ Use `--watch` only when the user wants the local Runtime to follow model-file edits. Use `--prune` or
126
+ bundle replacement only when the user clearly asks for those changes.
86
127
 
87
- The granular commands below remain available for manual troubleshooting and resumption. Do not expand
88
- the composite commands into this list during a normal Harness turn.
128
+ ## Iteration and troubleshooting
129
+
130
+ The granular commands remain available when a specific stage needs repair:
89
131
 
90
132
  ```text
91
133
  onboard-plan --connection-file <json> --profile <profile>
92
- datasource-configure --profile <profile>
93
- datasource-configure --profile <profile> --apply
94
- datasource-verify --profile <profile>
95
- datasource-verify --profile <profile> --bind
96
- schema-discover --profile <profile> --include-indexes
134
+ datasource-configure --profile <profile> [--apply]
135
+ datasource-verify --profile <profile> [--bind]
136
+ schema-discover --profile <profile> [--include-indexes]
97
137
  semantic-draft --profile <profile> --semantic-plan <json>
98
- semantic-validate --profile <profile>
99
- semantic-validate --profile <profile> --apply
100
- semantic-publish --profile <profile>
101
- semantic-publish --profile <profile> --apply
102
- semantic-verify --profile <profile> --project-root <current-session-workspace> --query-payload <json>
103
- semantic-verify --profile <profile> --project-root <current-session-workspace> --query-payload <json> --execute
138
+ semantic-validate --profile <profile> [--apply]
139
+ semantic-publish --profile <profile> [--apply]
140
+ semantic-verify --profile <profile> --query-payload <json> [--execute]
104
141
  onboard-status --profile <profile>
142
+ onboard-resume --profile <profile>
105
143
  ```
106
144
 
107
- The first `datasource-configure` call is a dry run. Explain the concrete datasource mutation and get
108
- approval before adding `--apply`. `datasource-verify` tests connectivity without binding; explain the
109
- namespace binding mutation and get approval before adding `--bind`. Add `--replace` only when the user
110
- explicitly approves replacing an existing datasource definition.
111
-
112
- Schema discovery is metadata-only and inspects at most 25 tables by default. Use repeated `--schema` or
113
- `--table` arguments to narrow scope, `--list-only` for inventory only, and raise `--max-tables` only when
114
- the user needs broader inspection. The resulting evidence remains under the private Runtime data root.
115
-
116
- ## Semantic authoring and publishing
117
-
118
- After `schemaDiscovered=completed`, review table names, columns, keys, and relationships with the user.
119
- Use `foggy-ai-analysis` for TM/QM authoring in a separate project-local draft directory. Do not invent
120
- business definitions, joins, units, enum meanings, or date semantics. Create a plan using
121
- `assets/semantic-plan.schema.json`; its declared query-model names must exist in the draft `.qm` files.
122
-
123
- `semantic-draft` records TM/QM hashes. Any later file change invalidates the recorded validation and must
124
- be registered and validated again. `semantic-validate` is a dry run until `--apply`; applying it may
125
- replace the Runtime validation catalog, so explain that mutation before approval.
126
-
127
- `semantic-publish` shows added, updated, unchanged, preserved, and optionally removed files. Applying it:
145
+ A standalone `datasource-configure --apply` can resolve `passwordEnv` from its current Agent process.
146
+ For a direct `password`, use the composite datasource command with the original connection file so the
147
+ secret stays ephemeral to that invocation.
128
148
 
129
- 1. backs up every overwritten or pruned project model file;
130
- 2. copies the registered draft;
131
- 3. validates the published directory;
132
- 4. registers the bundle;
133
- 5. refreshes only the declared query models.
149
+ When a failure occurs, repair only the failed input and rerun the same composite command. Do not remove
150
+ a successfully registered Bundle merely because later query validation failed. Keep SQL samples small,
151
+ read-only, and relevant to semantic authoring.
134
152
 
135
- Use `--prune` only when the user approves removing target-only TM/QM files. Use `--replace-bundle` only
136
- when the user approves replacing an existing Runtime bundle, and `--watch` only when file watching is
137
- desired. A failure before refresh restores project files; a refresh failure is reported as a partial
138
- Runtime publication and must be diagnosed before retrying.
153
+ ## Git handoff
139
154
 
140
- For verification, build a project-local query payload only from `models describe` field names. The helper
141
- requires an integer `limit` from 1 through 100. The first `semantic-verify` call lists/describes models and
142
- validates the query; only `--execute` reads business data. Full results stay in evidence and the command
143
- returns only counts and paths.
155
+ When validation and representative questions pass, recommend placing the model directory under the
156
+ user's existing Git repository. Git is the source of truth for model history; Runtime Bundle
157
+ registration only makes a selected local directory active. Do not create commits, remotes, tags, or
158
+ pushes without the user's request.
144
159
 
145
- Before the first semantic mutation, the composite command checks that the query payload is inside
146
- `projectRoot`, has a bounded limit, and targets a query model declared in the approved semantic plan.
147
- After publication, `semantic-verify` always describes the live model before validation. If a field is
148
- rejected, update the payload from those described names and rerun the same composite command.
160
+ ## Production handoff
149
161
 
150
- Do not open, summarize, or quote `query-execute.json` or the Runtime's generated SQL after execution.
151
- The conversational result may contain only `queryValidated`, `queryExecuted`, `rowCount`, the model
152
- name, and the evidence path. A successful direct CLI command is not proof that onboarding completed;
153
- only the wrapper's persisted state with all steps `completed` is authoritative.
162
+ Stop the local onboarding flow when the user asks to publish or update a formal environment. A separate
163
+ manual or dedicated deployment workflow should collect the exact target, Launcher version, model Git
164
+ commit/tag, namespace, production datasource procedure, access credentials, verification plan, and
165
+ rollback point. It should then install/start Runtime if needed, prepare the target datasource, register
166
+ the versioned model directory, refresh, and run a narrow smoke check.
154
167
 
155
- Do not bypass a failed step. If a command fails, report its structured error, fix only the relevant input
156
- or environment, and run `onboard-resume` to continue from the first incomplete step.
168
+ Local onboarding credentials and approvals do not authorize production access or publication.
@@ -26,5 +26,7 @@ if (-not $pythonCommand -or -not (Test-Path -LiteralPath $pythonCommand)) {
26
26
  exit 1
27
27
  }
28
28
 
29
+ $env:PYTHONUTF8 = '1'
30
+ $env:PYTHONIOENCODING = 'utf-8'
29
31
  & $pythonCommand (Join-Path $PSScriptRoot 'onboarding.py') @OnboardingArgs
30
32
  exit $LASTEXITCODE