@lincyaw/workspace 1.0.0-rc.100 → 1.0.0-rc.101

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/workspace",
3
- "version": "1.0.0-rc.100",
3
+ "version": "1.0.0-rc.101",
4
4
  "description": "Presmium's workspace service (presmium serve): documents, their history, reviews and the workspace site",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -34,13 +34,13 @@
34
34
  "mime-types": "3.0.2",
35
35
  "playwright-chromium": "1.64.1",
36
36
  "yaml": "^2.9.1",
37
- "@lincyaw/compiler": "1.0.0-rc.100",
38
- "@lincyaw/kernel": "1.0.0-rc.100",
39
- "@lincyaw/server": "1.0.0-rc.100",
40
- "@lincyaw/design": "1.0.0-rc.100"
37
+ "@lincyaw/compiler": "1.0.0-rc.101",
38
+ "@lincyaw/kernel": "1.0.0-rc.101",
39
+ "@lincyaw/design": "1.0.0-rc.101",
40
+ "@lincyaw/server": "1.0.0-rc.101"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/mime-types": "^3.0.1",
44
- "@lincyaw/mcp": "1.0.0-rc.100"
44
+ "@lincyaw/mcp": "1.0.0-rc.101"
45
45
  }
46
46
  }
package/src/node/git.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { execFile, execFileSync } from 'node:child_process'
2
- import { realpathSync } from 'node:fs'
2
+ import { existsSync, readdirSync, realpathSync } from 'node:fs'
3
+ import { join } from 'node:path'
4
+ import { promisify } from 'node:util'
3
5
  import { gitConfigArgs, gitEnvironment } from '@lincyaw/kernel'
4
6
 
5
7
  export interface GitResult {
@@ -26,6 +28,19 @@ export class Git {
26
28
  }
27
29
  }
28
30
 
31
+ /** Prepare a new, empty authoring workspace; existing content needs its own real history baseline. */
32
+ static async initialize(root: string): Promise<void> {
33
+ if (Git.isRepository(root) || existsSync(join(root, '.git'))) return
34
+ if (readdirSync(root).some(name => name !== '.DS_Store')) return
35
+ await promisify(execFile)('git', [...gitConfigArgs(), 'init', '--quiet', '--initial-branch=main'], { cwd: root, env: gitEnvironment(process.env) })
36
+ const git = new Git(root)
37
+ const tree = await git.run(['hash-object', '-w', '-t', 'tree', '--stdin'], {}, new Uint8Array())
38
+ if (tree.code !== 0) throw new Error(tree.stderr)
39
+ const commit = (await git.output(['-c', 'user.name=Presmium', '-c', 'user.email=workspace@presmium.invalid', 'commit-tree', tree.stdout.toString('utf8').trim(), '-m', 'Initialize workspace history'])).trim()
40
+ const ref = (await git.output(['symbolic-ref', 'HEAD'])).trim()
41
+ await git.output(['update-ref', ref, commit, '0'.repeat(commit.length)])
42
+ }
43
+
29
44
  run(command: string[], env: Record<string, string> = {}, input?: Uint8Array): Promise<GitResult> {
30
45
  return new Promise((done) => {
31
46
  let inputError: Error | undefined
package/src/node/serve.ts CHANGED
@@ -140,6 +140,7 @@ async function startWorkspace(options: ServeOptions): Promise<WorkspaceServer> {
140
140
  const config = readWorkspaceConfig(options.dir)
141
141
  if (env.PRESMIUM_AGENT_CANDIDATE === '1') config.settings['presmium.assistant'] = { ...config.settings['presmium.assistant'], review: 'auto' }
142
142
  const { root } = config
143
+ await Git.initialize(root).catch(error => log.warn(`the workspace history could not be prepared: ${errorMessage(error)}`))
143
144
  const operatorDirectory = resolveOperatorDir(root, options.operatorDir ?? env.PRESMIUM_OPERATOR_DIR)
144
145
  const speechSettings = new OperatorSpeechSettings(operatorDirectory, name => env[name])
145
146
  const stateDir = makeStateDir(root, env)